Exemplo n.º 1
0
 def test_ignores_whitespace_when_hashing(self):
     a1 = models.UserAddress(first_name=" Terry  ",
                             last_name='Barrington',
                             line1="  75 Smith Road  ",
                             postcode="  n4 8ty",
                             country=self.country)
     a1.clean()
     a2 = models.UserAddress(first_name=" Terry",
                             last_name='   Barrington',
                             line1="  75 Smith Road  ",
                             postcode="N4 8ty",
                             country=self.country)
     a2.clean()
     self.assertEqual(a1.generate_hash(), a2.generate_hash())
Exemplo n.º 2
0
 def test_can_be_hashed_including_non_ascii(self):
     a = models.UserAddress(first_name=u"\u0141ukasz Smith",
                            last_name=u'Smith',
                            line1=u"75 Smith Road",
                            postcode=u"n4 8ty")
     hash = a.generate_hash()
     self.assertTrue(hash is not None)
Exemplo n.º 3
0
 def test_converts_postcode_to_uppercase_when_cleaning(self):
     address = models.UserAddress(last_name='Barrington',
                                  line1="75 Smith Road",
                                  postcode="n4 8ty",
                                  country=self.country)
     address.clean()
     self.assertEqual("N4 8TY", address.postcode)
Exemplo n.º 4
0
 def test_strips_whitespace_when_cleaning(self):
     a = models.UserAddress(last_name='Barrington',
                            line1="  75 Smith Road  ",
                            postcode="  n4 8ty",
                            country=self.country)
     a.clean()
     self.assertEqual("N4 8TY", a.postcode)
     self.assertEqual("75 Smith Road", a.line1)
Exemplo n.º 5
0
 def test_active_address_fields_skips_whitespace_only_fields(self):
     a = models.UserAddress(first_name="   ",
                            last_name='Barrington',
                            line1="  75 Smith Road  ",
                            postcode="  n4 8ty",
                            country=self.country)
     active_fields = a.active_address_fields()
     self.assertEqual("Barrington", active_fields[0])
Exemplo n.º 6
0
 def test_has_summary_property(self):
     a = models.UserAddress(title="Dr",
                            first_name="Barry",
                            last_name='Barrington',
                            line1="1 King Road",
                            line4="London",
                            postcode="SW1 9RE")
     self.assertEqual("Dr Barry Barrington, 1 King Road, London, SW1 9RE",
                      a.summary)
Exemplo n.º 7
0
 def test_can_be_hashed(self):
     a = models.UserAddress(title="Dr",
                            first_name="Barry",
                            last_name='Barrington',
                            line1="1 King Road",
                            line4="London",
                            postcode="SW1 9RE")
     hash = a.generate_hash()
     self.assertTrue(hash is not None)
Exemplo n.º 8
0
 def test_summary_is_property(self):
     a = models.UserAddress(first_name=" Terry  ",
                            last_name='Barrington',
                            line1="  75 Smith Road  ",
                            postcode="  n4 8ty",
                            country=self.country)
     a.clean()
     self.assertEqual(
         u"Terry Barrington, 75 Smith Road, N4 8TY, UNITED KINGDOM",
         a.summary)
Exemplo n.º 9
0
 def test_populated_shipping_address_has_same_summary_user_address(self):
     a = models.UserAddress(first_name=" Terry  ",
                            last_name='Barrington',
                            line1="  75 Smith Road  ",
                            postcode="  n4 8ty",
                            country=self.country)
     a.clean()
     sa = ShippingAddress()
     a.populate_alternative_model(sa)
     self.assertEqual(sa.summary, a.summary)
Exemplo n.º 10
0
 def test_populate_shipping_address_doesnt_set_id(self):
     a = models.UserAddress(first_name=" Terry  ",
                            last_name='Barrington',
                            line1="  75 Smith Road  ",
                            postcode="  n4 8ty",
                            country=self.country)
     a.clean()
     sa = ShippingAddress()
     a.populate_alternative_model(sa)
     self.assertIsNone(sa.id)
Exemplo n.º 11
0
 def test_summary_includes_country(self):
     c = models.Country(pk=1, iso_3166_1_a2="GB", name="UNITED KINGDOM")
     a = models.UserAddress(title="Dr",
                            first_name="Barry",
                            last_name='Barrington',
                            line1="1 King Road",
                            line4="London",
                            postcode="SW1 9RE",
                            country=c)
     self.assertEqual(
         "Dr Barry Barrington, 1 King Road, London, SW1 9RE, UNITED KINGDOM",
         a.summary)
Exemplo n.º 12
0
def test_assert_valid_postcode(country_value, postcode_value):
    country = models.Country(iso_3166_1_a2=country_value)
    address = models.UserAddress(country=country, postcode=postcode_value)
    address.clean()
Exemplo n.º 13
0
def test_assert_invalid_postcode(country_value, postcode_value):
    country = models.Country(iso_3166_1_a2=country_value)
    address = models.UserAddress(country=country, postcode=postcode_value)

    with pytest.raises(exceptions.ValidationError):
        address.clean()
Exemplo n.º 14
0
 def test_uses_title_firstname_and_lastname_in_salutation(self):
     a = models.UserAddress(title="Dr",
                            first_name="Barry",
                            last_name='Barrington')
     self.assertEqual("Dr Barry Barrington", a.salutation)
Exemplo n.º 15
0
 def test_strips_whitespace_from_salutation(self):
     a = models.UserAddress(last_name='Barrington')
     self.assertEqual("Barrington", a.salutation)
Exemplo n.º 16
0
 def test_uses_city_as_an_alias_of_line4(self):
     a = models.UserAddress(last_name='Barrington',
                            line1="75 Smith Road",
                            line4="London",
                            postcode="n4 8ty")
     self.assertEqual('London', a.city)
Exemplo n.º 17
0
 def test_strips_whitespace_in_name_property(self):
     a = models.UserAddress(last_name='Barrington')
     self.assertEqual("Barrington", a.name)
Exemplo n.º 18
0
 def test_has_name_property(self):
     a = models.UserAddress(title="Dr",
                            first_name="Barry",
                            last_name='Barrington')
     self.assertEqual("Barry Barrington", a.name)