本文整理汇总了Python中application.Application.from_configs方法的典型用法代码示例。如果您正苦于以下问题:Python Application.from_configs方法的具体用法?Python Application.from_configs怎么用?Python Application.from_configs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类application.Application
的用法示例。
在下文中一共展示了Application.from_configs方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initialize
# 需要导入模块: from application import Application [as 别名]
# 或者: from application.Application import from_configs [as 别名]
def initialize(self):
try:
web_config = self._get_web_config()
for web_app in web_config['applications']:
file_app = self._get_file_config(web_app['id'])
if file_app:
self._applications.append(Application.from_configs(web_app, file_app))
else:
self._applications.append(Application.from_configs(web_app))
except ConfigException as cfgex:
return (False, cfgex.error_code, cfgex.message)
return (True, "0", "Success")
示例2: test_actions_should_be_remove_and_upgrade_if_version_of_installed_not_equal_to_new_version
# 需要导入模块: from application import Application [as 别名]
# 或者: from application.Application import from_configs [as 别名]
def test_actions_should_be_remove_and_upgrade_if_version_of_installed_not_equal_to_new_version(self):
installed_config = self.get_sample_installed_config()
web_config = self.get_sample_application_config()
installed_config['current_version'] = '2.3.4'
web_config['available_version'] = '2.4.4'
app = Application.from_configs(web_config, installed_config)
self.assertEquals(2, len(app.actions))
self.assertTrue('remove' in app.actions)
self.assertTrue('upgrade' in app.actions)
示例3: test_actions_should_be_remove_if_version_of_installed_equal_to_new_version
# 需要导入模块: from application import Application [as 别名]
# 或者: from application.Application import from_configs [as 别名]
def test_actions_should_be_remove_if_version_of_installed_equal_to_new_version(self):
installed_config = self.get_sample_installed_config()
web_config = self.get_sample_application_config()
installed_config['current_version'] = '2.3.4'
web_config['available_version'] = '2.3.4'
app = Application.from_configs(web_config, installed_config)
print app.actions
self.assertEquals(1, len(app.actions))
self.assertEquals('remove', app.actions[0])
示例4: test_get_item_responds_with_specific_application
# 需要导入模块: from application import Application [as 别名]
# 或者: from application.Application import from_configs [as 别名]
def test_get_item_responds_with_specific_application(self, mock_urllib2, mock_exists):
mock_exists.return_value = False
mock_urllib2.urlopen.return_value = self.make_mock_response(code=200, data=self.get_sample_web_config())
expected_app = Application.from_configs(self.get_sample_application_config())
test_installer_api = InstallerAPI('config_url')
result = test_installer_api.initialize()
self.assertTrue(result[0])
app = test_installer_api.get_item(expected_app.id)
self.assertEquals(expected_app, app)
示例5: test_get_items_should_return_a_list_of_available_items
# 需要导入模块: from application import Application [as 别名]
# 或者: from application.Application import from_configs [as 别名]
def test_get_items_should_return_a_list_of_available_items(self, mock_urllib2, mock_exists):
mock_exists.return_value = False
test_installer_api = InstallerAPI('config_url')
sample = '{"version": 0, "applications":[%s]}' % json.dumps(self.get_sample_application_config())
expected_result = [Application.from_configs(self.get_sample_application_config())]
mock_urllib2.urlopen.return_value = self.make_mock_response(code=200, data=sample)
init_result = list(test_installer_api.initialize())
self.assertTrue(init_result[0], init_result[2])
result = test_installer_api.get_items()
self.assertEqual(expected_result, result)
示例6: test_process_should_create_and_start_an_upgrader_for_item_if_install_true
# 需要导入模块: from application import Application [as 别名]
# 或者: from application.Application import from_configs [as 别名]
def test_process_should_create_and_start_an_upgrader_for_item_if_install_true(self, mock_AsyncActionHandler, mock_urllib2, mock_exists):
mock_exists.return_value = False
mock_urllib2.urlopen.return_value = self.make_mock_response(code=200, data=self.get_sample_web_config())
expected_app = Application.from_configs(self.get_sample_application_config())
test_installer_api = InstallerAPI('config_url')
result = test_installer_api.initialize()
self.assertTrue(result[0], result)
test_installer_api.process(expected_app.id, 'base_folder', action='upgrade', status_callback='status_callback', complete_callback='complete_callback')
mock_AsyncActionHandler.assert_called_with('upgrade', expected_app, 'base_folder', status_callback='status_callback', complete_callback='complete_callback')
mock_AsyncActionHandler.return_value.start.assert_called_with()
示例7: test_process_should_raise_if_nothing_selected
# 需要导入模块: from application import Application [as 别名]
# 或者: from application.Application import from_configs [as 别名]
def test_process_should_raise_if_nothing_selected(self, mock_AsyncActionHandler, mock_urllib2, mock_exists):
mock_exists.return_value = False
mock_urllib2.urlopen.return_value = self.make_mock_response(code=200, data=self.get_sample_web_config())
expected_app = Application.from_configs(self.get_sample_application_config())
test_installer_api = InstallerAPI('config_url')
result = test_installer_api.initialize()
self.assertTrue(result[0], result)
with self.assertRaises(Exception):
test_installer_api.process(expected_app.id, 'base_folder', action='wrong', status_callback='status_callback', complete_callback='complete_callback')
mock_AsyncActionHandler.assert_not_called()
示例8: test_has_correct_fields
# 需要导入模块: from application import Application [as 别名]
# 或者: from application.Application import from_configs [as 别名]
def test_has_correct_fields(self):
installed_config = self.get_sample_installed_config()
web_config = self.get_sample_application_config()
app = Application.from_configs(web_config, installed_config)
self.assertEquals(web_config['id'], app.id)
self.assertEquals(web_config['name']['en-us'], app.name)
self.assertEquals(installed_config['current_version'], app.current_version)
self.assertEquals(web_config['available_version'], app.available_version)
self.assertEquals(web_config['location'], app.download_location)
self.assertEquals(web_config['install_path'], app.relitive_install_path)
self.assertEquals(installed_config['installed_path'], app.installed_path)
self.assertEquals(installed_config['shortcut_path'], app.shortcut_path)
self.assertEquals(web_config['executable'], app.executable_path)
示例9: test_initialize_should_create_correct_application
# 需要导入模块: from application import Application [as 别名]
# 或者: from application.Application import from_configs [as 别名]
def test_initialize_should_create_correct_application(self, mock_urllib2, mock_exists):
mock_exists.return_value = True
mock_urllib2.urlopen.return_value = self.make_mock_response(code=200, data=self.get_sample_web_config())
mock_open_file = mock_open(read_data=json.dumps(self.get_sample_installed_config()))
expected_app = Application.from_configs(self.get_sample_application_config(), self.get_sample_installed_config())
with patch('installer_api.open', mock_open_file, create=True):
test_installer_api = InstallerAPI('config_url')
result = test_installer_api.initialize()
self.assertTrue(result[0])
apps = test_installer_api.get_items()
self.assertEquals(1, len(apps))
self.assertEquals(expected_app, apps[0])
示例10: test_actions_should_be_install_if_no_existing_version
# 需要导入模块: from application import Application [as 别名]
# 或者: from application.Application import from_configs [as 别名]
def test_actions_should_be_install_if_no_existing_version(self):
web_config = self.get_sample_application_config()
app = Application.from_configs(web_config)
self.assertEquals(1, len(app.actions))
self.assertEquals('install', app.actions[0])
示例11: test_two_identical_applications_are_equal
# 需要导入模块: from application import Application [as 别名]
# 或者: from application.Application import from_configs [as 别名]
def test_two_identical_applications_are_equal(self):
installed_config = self.get_sample_installed_config()
web_config = self.get_sample_application_config()
app1 = Application.from_configs(web_config, installed_config)
app2 = Application.from_configs(web_config, installed_config)
self.assertEquals(app1, app2)
示例12: test_uses_web_config_name_if_name_do_not_match
# 需要导入模块: from application import Application [as 别名]
# 或者: from application.Application import from_configs [as 别名]
def test_uses_web_config_name_if_name_do_not_match(self):
file_config = self.get_sample_installed_config()
file_config['name'] = 'Bad Wolf'
web_config = self.get_sample_application_config()
app = Application.from_configs(web_config, file_config)
self.assertEquals(web_config['name']['en-us'], app.name)
示例13: test_raises_exception_if_ids_do_not_match
# 需要导入模块: from application import Application [as 别名]
# 或者: from application.Application import from_configs [as 别名]
def test_raises_exception_if_ids_do_not_match(self):
file_config = self.get_sample_installed_config()
file_config['id'] = 234
web_config = self.get_sample_installed_config()
with self.assertRaises(Exception):
Application.from_configs(web_config, file_config)
示例14: get_application
# 需要导入模块: from application import Application [as 别名]
# 或者: from application.Application import from_configs [as 别名]
def get_application(self):
return Application.from_configs(self.get_sample_application_config())