Пример #1
0
 def test_assignment_from_dict_with_subpremise(self):
     ad2_dict = {
         'raw': '10855 S River Front Pkwy #300, South Jordan, UT, US',
         'street_number': '10855',
         'route': 'River Front Pkwy',
         'subpremise': '300',
         'locality': 'South Jordan',
         'postal_code': '84095',
         'state': 'Utah',
         'state_code': 'UT',
         'country': 'United States',
         'country_code': 'US'
     }
     subpremise_address = to_python(ad2_dict)
     self.assertEqual(subpremise_address.raw, ad2_dict['raw'])
     self.assertEqual(subpremise_address.street_number,
                      ad2_dict['street_number'])
     self.assertEqual(subpremise_address.route, ad2_dict['route'])
     self.assertEqual(subpremise_address.subpremise, ad2_dict['subpremise'])
     self.assertEqual(subpremise_address.locality.name,
                      ad2_dict['locality'])
     self.assertEqual(subpremise_address.locality.postal_code,
                      ad2_dict['postal_code'])
     self.assertEqual(subpremise_address.locality.state.name,
                      ad2_dict['state'])
     self.assertEqual(subpremise_address.locality.state.code,
                      ad2_dict['state_code'])
     self.assertEqual(subpremise_address.locality.state.country.name,
                      ad2_dict['country'])
     self.assertEqual(subpremise_address.locality.state.country.code,
                      ad2_dict['country_code'])
Пример #2
0
 def test_assignment_from_dict_only_address(self):
     ad = {
         'raw': '1 Somewhere Street, Northcote, Victoria 3070, VIC, AU',
         'street_number': '1',
         'route': 'Somewhere Street',
     }
     self.address = to_python(ad)
     self.assertEqual(self.address.raw, ad['raw'])
     self.assertEqual(self.address.street_number, ad['street_number'])
     self.assertEqual(self.address.route, ad['route'])
     self.assertEqual(self.address.locality, None)
Пример #3
0
 def test_assignment_from_dict_no_state(self):
     ad = {
         'raw': 'Somewhere',
         'locality': 'Northcote',
         'country': 'Australia',
     }
     self.address = to_python(ad)
     self.assertEqual(self.address.raw, ad['raw'])
     self.assertEqual(self.address.street_number, '')
     self.assertEqual(self.address.route, '')
     self.assertEqual(self.address.locality, None)
Пример #4
0
 def test_assignment_from_dict_no_locality(self):
     ad = {
         'raw': '1 Somewhere Street, Northcote, Victoria 3070, VIC, AU',
         'street_number': '1',
         'route': 'Somewhere Street',
         'state': 'Victoria',
         'country': 'Australia',
     }
     self.address = to_python(ad)
     self.assertEqual(self.address.raw, ad['raw'])
     self.assertEqual(self.address.street_number, '')
     self.assertEqual(self.address.route, '')
     self.assertEqual(self.address.locality, None)
Пример #5
0
 def test_assignment_from_dict_duplicate_state_code(self):
     ad = {
         'raw': '1 Somewhere Street, Northcote, Victoria 3070, VIC, AU',
         'street_number': '1',
         'route': 'Somewhere Street',
         'locality': 'Northcote',
         'state': 'Victoria',
         'state_code': 'Victoria',
         'country': 'Australia',
     }
     self.address = to_python(ad)
     self.assertEqual(self.address.raw, ad['raw'])
     self.assertEqual(self.address.street_number, '1')
     self.assertEqual(self.address.route, 'Somewhere Street')
     self.assertEqual(self.address.locality.name, 'Northcote')
     self.assertEqual(self.address.locality.state.name, 'Victoria')
     self.assertEqual(self.address.locality.state.code, '')
     self.assertEqual(self.address.locality.state.country.name, 'Australia')
Пример #6
0
 def test_assignment_from_dict(self):
     self.address = to_python(self.ad1_dict)
     self.assertEqual(self.address.raw, self.ad1_dict['raw'])
     self.assertEqual(self.address.street_number,
                      self.ad1_dict['street_number'])
     self.assertEqual(self.address.route, self.ad1_dict['route'])
     self.assertEqual(self.address.subpremise, '')
     self.assertEqual(self.address.locality.name, self.ad1_dict['locality'])
     self.assertEqual(self.address.locality.postal_code,
                      self.ad1_dict['postal_code'])
     self.assertEqual(self.address.locality.state.name,
                      self.ad1_dict['state'])
     self.assertEqual(self.address.locality.state.code,
                      self.ad1_dict['state_code'])
     self.assertEqual(self.address.locality.state.country.name,
                      self.ad1_dict['country'])
     self.assertEqual(self.address.locality.state.country.code,
                      self.ad1_dict['country_code'])
Пример #7
0
 def test_assignment_from_string(self):
     self.address = to_python(self.ad1_dict['raw'])
     self.assertEqual(self.address.raw, self.ad1_dict['raw'])