def test_config_structure3(self): with self.assertRaises(ConfigElementTypeError) as c: get_app_config_from( load_yaml_from_test_dir('app_list_invalid_versions')) self.assertEqual(c.exception.expected, list) self.assertEqual(c.exception.received, str) self.assertEqual(c.exception.config_path, ConfigPath('$[1].versions'))
def test_excessive_attribute2(self): with self.assertRaises(ConfigExcessiveAttributeError) as c: get_app_config_from( load_yaml_from_test_dir( 'advanced_config_excessive_attribute2.yml')) self.assertEqual(c.exception.config_path, ConfigPath('$[0].architectures[0].version'))
def test_incomplete_branches(self): with self.assertRaises(ConfigIncompleteBranchesError) as c: get_app_config_from( load_yaml_from_test_dir( 'advanced_config_incomplete_branches.yml')) self.assertSequenceEqual(c.exception.config_paths, [ConfigPath('$[0].architectures[0]')]) self.assertSetEqual(c.exception.attributes, {'version'})
def test_processing2(self): fb = NonCallableMock(spec_set=Feedback) set_install_manager_data(True, True, 'example3_final:1.0\r\nexample3:1.1') set_download_manager_data(set()) data = get_app_config_from(load_yaml_from_test_dir('app_list')) software_processor.process('C:\\temp', data, fb) fb.report_checking_software.assert_called_once() download_manager.filter_present.assert_called_once_with([]) download_manager.download.assert_not_called() install_manager.install_msi.assert_not_called() install_manager.remove_file.assert_called_once_with(Path('C:/temp/example4'), 'example4.exe') install_manager.remove_directory.assert_called_once_with(Path('C:/temp/example5/0.5')) self.assert_called_exactly_with_no_order(install_manager.run_file, call('C:\\Program Files\\Example1\\1.0\\uninstall.exe', None)) self.assert_called_exactly_with_no_order(install_manager.run_command, call('manager', ['list']), call('manager', ['list']), call('manager', ['uninstall', 'example3_final:1.0'])) self.assert_called_exactly_with_no_order(install_manager.uninstall_msi, call('pc1235', ['/q'])) fb.confirm_operations.assert_called_once_with([], list(data.to_uninstall), []) fb.report_installation_started.assert_not_called() fb.report_installation_finished.assert_not_called() fb.report_removal_started.assert_called_once() fb.report_removal_finished.assert_called_once() self.assert_called_exactly_with_no_order(fb.report_entry_removal_started, *(call(item) for item in data.to_uninstall)) self.assert_called_exactly_with_no_order(fb.report_entry_removal_finished, *(call(item) for item in data.to_uninstall)) fb.report_entry_installation_started.assert_not_called() fb.report_entry_installation_finished.assert_not_called()
def test_app_list_processing3(self): ac = get_app_config_from( load_yaml_from_test_dir('app_list_no_versions')) self.assertSequenceEqual(ac.to_uninstall, [ AppEntry(name='test2', version='1.0'), AppEntry(name='test', version='1.0') ])
def test_app_list_processing2(self): with self.assertRaises(ConfigDuplicatedEntryIdentityError) as c: get_app_config_from( load_yaml_from_test_dir('app_list_duplicated_name_version')) self.assertSequenceEqual( c.exception.config_paths, [ConfigPath('$[0]'), ConfigPath('$[0].versions[0]')]) self.assertSequenceEqual( c.exception.another_paths, [ConfigPath('$[1]'), ConfigPath('$[1].versions[0]')]) self.assertDictEqual(c.exception.identity_values, { 'architecture': None, 'name': 'test', 'version': '1.0' })
def test_config_data_processing(self): data = load_yaml_from_test_dir('advanced_config_structure') items = get_app_config_from(data) to_install = [ AppEntry(name='test', version='0.3', architecture='x86_64', keep=True, file_hash='5'), AppEntry(name='test', version='0.2', architecture='x86_64', keep=True, file_hash='6'), AppEntry(name='test2', version='0.3', architecture='x86_64', keep=True, file_hash='5'), AppEntry(name='test2', version='0.1', architecture='x86', keep=True, file_hash='7') ] to_uninstall = [ AppEntry(name='test', version='999.1', architecture='x86_128', file_hash='4'), AppEntry(name='test', version='0.1', architecture='x86', file_hash='7'), AppEntry(name='test2', version='999.1', architecture='x86_128', file_hash='4'), AppEntry(name='test2', version='0.2', architecture='x86_64', file_hash='6') ] self.assertSequenceEqual(items.to_install, to_install) self.assertSequenceEqual(items.to_uninstall, to_uninstall)
def test_processing(self): fb = NonCallableMock(spec_set=Feedback) set_install_manager_data(False, False, '') set_download_manager_data({'C:\\temp\\example2\\0.1b\\example2_0.1b.msi'}) data = get_app_config_from(load_yaml_from_test_dir('app_list')) software_processor.process('C:\\temp', data, fb) specs = [exe_install_handler.create_download_spec(data.to_install[0], 'C:\\temp'), msi_install_handler.create_download_spec(data.to_install[1], 'C:\\temp'), file_install_handler.create_download_spec(data.to_install[3], 'C:\\temp'), archive_install_handler.create_download_spec(data.to_install[4], 'C:\\temp')] download_manager.filter_present.assert_called_once_with(specs) download_manager.download.assert_called_once_with(specs[:1] + specs[2:], fb) fb.report_checking_software.assert_called_once() install_manager.uninstall_msi.assert_not_called() install_manager.copy_file.assert_called_once_with('C:\\temp\\example4\\x86_64\\example4_x86_64.exe', Path('C:/temp/example4'), 'example4.exe') install_manager.unpack_archive.assert_called_once_with(r'C:\temp\example5\0.6\x86_64\example5_0.6_x86_64.zip', 'zip', Path('C:/temp/example5/0.6')) self.assert_called_exactly_with_no_order(install_manager.run_file, call('C:\\temp\\example1\\1.1\\example1_1.1.exe', ['/SILENT', '/DIR=C:\\Program Files\\Example1\\1.1'])) self.assert_called_exactly_with_no_order(install_manager.run_command, call('manager', ['list']), call('manager', ['list']), call('manager', ['install', 'example3:1.1'])) self.assert_called_exactly_with_no_order(install_manager.install_msi, call('C:\\temp\\example2\\0.1b\\example2_0.1b.msi', ['/q', 'INSTALLDIR=C:\\Program Files\\Example2'])) fb.confirm_operations.assert_called_once_with(specs[:1] + specs[2:], [], list(data.to_install)) fb.report_removal_started.assert_not_called() fb.report_removal_finished.assert_not_called() fb.report_installation_started.assert_called_once() fb.report_installation_finished.assert_called_once() self.assert_called_exactly_with_no_order(fb.report_entry_installation_started, *(call(item) for item in data.to_install)) self.assert_called_exactly_with_no_order(fb.report_entry_installation_finished, *(call(item) for item in data.to_install)) fb.report_entry_removal_started.assert_not_called() fb.report_entry_removal_finished.assert_not_called()
def test_no_name(self): with self.assertRaises(ConfigRequiredAttributesNotFoundError) as c: get_app_config_from( load_yaml_from_test_dir('advanced_config_no_name')) self.assertEqual(c.exception.config_path, ConfigPath('$[1]')) self.assertSetEqual(c.exception.attributes, {'name'})
def test_app_list_processing(self): app_conf = get_app_config_from(load_yaml_from_test_dir('app_list')) self.assertEqual(len(app_conf.to_install), 5) self.assertEqual(len(app_conf.to_uninstall), 5)