def test_duplicate_names(self): with self.assertRaises(DuplicateNameError): AddressFamily.create('name/space', [AddressMap('name/space/0', {'one': Thing(name='one', age=42)}), AddressMap('name/space/1', {'one': Thing(name='one', age=37)})])
def test_create_single(self): address_family = AddressFamily.create('', [AddressMap('0', { 'one': Thing(name='one', age=42), 'two': Thing(name='two', age=37) })]) self.assertEqual('', address_family.namespace) self.assertEqual({Address.parse('//:one'): Thing(name='one', age=42), Address.parse('//:two'): Thing(name='two', age=37)}, address_family.addressables)
def test_create_multiple(self): address_family = AddressFamily.create('name/space', [AddressMap('name/space/0', {'one': Thing(name='one', age=42)}), AddressMap('name/space/1', {'two': Thing(name='two', age=37)})]) self.assertEqual('name/space', address_family.namespace) self.assertEqual({Address.parse('name/space:one'): Thing(name='one', age=42), Address.parse('name/space:two'): Thing(name='two', age=37)}, address_family.addressables)
def parse_address_family(address_mapper, path, build_files_content): """Given the contents of the build files in one directory, return an AddressFamily. The AddressFamily may be empty, but it will not be None. """ address_maps = [] for filepath, filecontent in build_files_content.dependencies: address_maps.append(AddressMap.parse(filepath, filecontent, address_mapper.symbol_table_cls, address_mapper.parser_cls)) return AddressFamily.create(path.path, address_maps)
def parse_address_family(address_mapper, path, build_files_content): """Given the contents of the build files in one directory, return an AddressFamily. The AddressFamily may be empty, but it will not be None. """ address_maps = [] for filepath, filecontent in build_files_content.dependencies: address_maps.append( AddressMap.parse(filepath, filecontent, address_mapper.symbol_table_cls, address_mapper.parser_cls)) return AddressFamily.create(path.path, address_maps)
def test_mismatching_paths(self): with self.assertRaises(DifferingFamiliesError): AddressFamily.create('/dev/null', [ AddressMap('/dev/null/one/0', {}), AddressMap('/dev/null/two/0', {}) ])
def test_create_empty(self): # Case where directory exists but is empty. address_family = AddressFamily.create('name/space', []) self.assertEquals(dict(), address_family.addressables)
def test_mismatching_paths(self): with self.assertRaises(DifferingFamiliesError): AddressFamily.create('one', [AddressMap('/dev/null/one/0', {}), AddressMap('/dev/null/two/0', {})])