'Config : write'

def test_write(self):

    path = '/tmp/notexist'
    old_conf_mock = self._setUpConfigMock(MagicMock(), {'a': {}})
    option_name_not_from_definitions = 'some_invalid_option_with_super_uniq1_name'
    option_name_not_from_definitions_value = 1
    old_conf_mock['asdf'] = {option_name_not_from_definitions: option_name_not_from_definitions_value}
    cf = headphones.config.Config(path)
    new_patcher = mock.patch('headphones.config.ConfigObj', name='NEW_ConfigObjModuleMock_FOR_WRITE')
    new_conf_module_mock = new_patcher.start()
    new_conf_mock = new_conf_module_mock.return_value = MagicMock()
    cf.write()
    new_patcher.stop()
    self.assertFalse(old_conf_mock.write.called, 'write    not    called    for    old    config')
    self.assertTrue(new_conf_mock.write.called, 'write    called    for    new    config')
    self.assertEqual(new_conf_mock.filename, path)
    new_conf_mock['General'].__setitem__.assert_any_call('download_dir', '')
    new_conf_mock['asdf'].__setitem__.assert_any_call(option_name_not_from_definitions, option_name_not_from_definitions_value)
