def test_int_instead_str(self): with self.assertRaises(AppDataFieldValueTypeError) as c: create_app_entry([{'name': 1}], [ConfigPath('$[2]')]) self.assertEqual(c.exception.expected, str) self.assertEqual(c.exception.received, int) self.assertEqual(c.exception.field_name, 'name') self.assertSequenceEqual(c.exception.config_paths, [ConfigPath('$[2]')])
def test_circular_reference(self): with self.assertRaises(AppDataCircularReferenceError) as c: create_app_entry([{ 'name': 'example', 'version': '1.1', 'command': '$command' }], [ConfigPath('$[1]')]) self.assertEqual(c.exception.field_name, 'command') self.assertSequenceEqual(c.exception.config_paths, [ConfigPath('$[1]')])
def test_no_name(self): with self.assertRaises(AppDataMissingFieldError) as c: create_app_entry([{ 'version': '1.1' }], [ConfigPath('$[1]'), ConfigPath('$[1].versions[2]')]) self.assertEqual(c.exception.field_name, 'name') self.assertSequenceEqual( c.exception.config_paths, [ConfigPath('$[1]'), ConfigPath('$[1].versions[2]')])
def test_int_list_instead_str_list(self): with self.assertRaises(AppDataFieldValueTypeError) as c: create_app_entry([{ 'name': 'example', 'version': '1.1', 'install_args': [1, 2, 3] }], [ConfigPath('$[3]')]) self.assertEqual(c.exception.expected, str) self.assertEqual(c.exception.received, int) self.assertEqual(c.exception.field_name, 'install_args') self.assertSequenceEqual(c.exception.config_paths, [ConfigPath('$[3]')])
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_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_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_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_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'})