예제 #1
0
 def location_has_address_of_type(self, address_type_id):
     LocationBuilder(self.organization).create()
     AddressBuilder().create()
     LocationAddress(
         location=Location.objects.first(),
         address=Address.objects.first(),
         address_type=AddressType.objects.get(pk=address_type_id)).save()
     url = '/v1/locations/'
     response = self.client.get(url)
     location_addresses = response.json()[0]['addresses']
     self.assertEqual(location_addresses[0]['address_type'],
                      address_type_id)
예제 #2
0
 def test_does_not_allow_duplicate_addresses(self):
     address = AddressBuilder().build()
     address_copy = copy(address)
     address.save()
     with self.assertRaises(exceptions.ValidationError):
         address_copy.save()
예제 #3
0
 def test_has_postal_code_field(self):
     address = AddressBuilder().build()
     address_from_db = validate_save_and_reload(address)
     self.assertEqual(address_from_db.postal_code, address.postal_code)
예제 #4
0
 def test_empty_postal_code_field_saves_as_null(self):
     AddressBuilder().with_postal_code('').create()
     self.assertTrue(Address.objects.first().postal_code is None)
예제 #5
0
 def test_has_state_province_field(self):
     address = AddressBuilder().build()
     address_from_db = validate_save_and_reload(address)
     self.assertEqual(address_from_db.state_province, address.state_province)
예제 #6
0
 def test_empty_state_province_field_saves_as_null(self):
     AddressBuilder().with_state_province('').create()
     self.assertTrue(Address.objects.first().state_province is None)
예제 #7
0
 def test_empty_attention_field_saves_as_null(self):
     AddressBuilder().with_attention('').create()
     self.assertTrue(Address.objects.first().attention is None)
예제 #8
0
 def test_has_attention_field(self):
     address = AddressBuilder().build()
     address_from_db = validate_save_and_reload(address)
     self.assertEqual(address_from_db.attention, address.attention)
예제 #9
0
 def test_country_fields_cannot_exceed_two_characters(self):
     three_character_string = a_string(3)
     address = AddressBuilder().with_country(three_character_string).build()
     with self.assertRaises(exceptions.ValidationError):
         validate_save_and_reload(address)
예제 #10
0
 def test_country_field_cannot_be_empty(self):
     with self.assertRaises(exceptions.ValidationError):
         AddressBuilder().with_country('').create()
예제 #11
0
 def test_has_country_field(self):
     address = AddressBuilder().build()
     address_from_db = validate_save_and_reload(address)
     self.assertEqual(address_from_db.country, address.country)