def test_handle_abnormal_occupancy(self): addr_str = '123 SW MAIN UN' expected = OrderedDict([ ('AddressNumber', '123'), ('StreetNamePreDirectional', 'SW'), ('StreetName', 'MAIN'), ('StreetNamePostType', 'UN'), ]) result = parse_address_string(addr_str) self.assertEqual(expected, result) addr_str = '123 SW MAIN UN A' expected = OrderedDict([('AddressNumber', '123'), ('StreetNamePreDirectional', 'SW'), ('StreetName', 'MAIN'), ('OccupancyType', 'UN'), ('OccupancyIdentifier', 'A')]) result = parse_address_string(addr_str) self.assertEqual(expected, result) addr_str = '123 SW MAIN UN, UN A' expected = OrderedDict([('AddressNumber', '123'), ('StreetNamePreDirectional', 'SW'), ('StreetName', 'MAIN'), ('StreetNamePostType', 'UN'), ('OccupancyType', 'UN'), ('OccupancyIdentifier', 'A')]) result = parse_address_string(addr_str) self.assertEqual(expected, result)
def test_parse_address_string(self): """Test parse_address_string function.""" result = parse_address_string(self.parseable_addr_str) self.assertIsInstance(result, OrderedDict) ambig_addr_str = 'AWBREY VILLAGE' with self.assertRaises(AmbiguousAddressError): parse_address_string(ambig_addr_str)