def test_missing_phone_number(self): # Is a valid address identified correctly? data = dict( user=self.johndoe, first_name="John", last_name="Doe", line1="123 No Such Street", line4="Brighton", postcode="BN1 6XX", country=self.uk.iso_3166_1_a2, ) form = UserAddressForm(self.johndoe, data) self.assertFalse(form.is_valid())
def test_vatin_wrong_country(self): # Is an invalid VATIN identified correctly? data = dict( user=self.hansmueller, first_name="Hans", last_name="Müller", line1="hastexo Professional Services GmbH", line4="Wien", postcode="1010", country=self.uk.iso_3166_1_a2, vatin='ATU66688202', ) form = UserAddressForm(self.hansmueller, data) self.assertFalse(form.is_valid())
def test_invalid_vatin(self): # Is an invalid VATIN identified correctly? data = dict( user=self.hansmueller, first_name="Hans", last_name="Müller", line1="hastexo Professional Services GmbH", line4="Wien", postcode="1010", country=self.at.iso_3166_1_a2, vatin='ATU99999999', ) form = UserAddressForm(self.hansmueller, data) self.assertFalse(form.is_valid())
def test_valid_vatin(self): # Is a valid VATIN identified correctly? data = dict( user=self.hansmueller, first_name="Hans", last_name="Müller", line1="hastexo Professional Services GmbH", line4="Wien", postcode="1010", country=self.at.iso_3166_1_a2, vatin='ATU66688202', phone_number='+43 1 555 9999', ) form = UserAddressForm(self.hansmueller, data) self.assertTrue(form.is_valid())
def test_non_matching_country_and_phone_number(self): # Is an invalid combination of country and phone number # identified correctly? data = dict( user=self.hansmueller, first_name="Hans", last_name="Müller", line1="Example, Inc.", line4="Wien", postcode="1010", phone_number="+49 30 1234567", country=self.at.iso_3166_1_a2, ) form = UserAddressForm(self.hansmueller, data) self.assertFalse(form.is_valid())
def test_non_matching_vatin(self): # Is a VATIN that is correct, but doesn't match the company # name, identified correctly? data = dict( user=self.hansmueller, first_name="Hans", last_name="Müller", line1="Example, Inc.", line4="Wien", postcode="1010", country=self.at.iso_3166_1_a2, vatin='ATU66688202', ) form = UserAddressForm(self.hansmueller, data) self.assertFalse(form.is_valid())
def test_non_matching_address_and_phone_number(self): # Is an invalid combination of postcode and phone area code, # where this information would be relevant for a VAT # exception, identified correctly? data = dict( user=self.hansmueller, first_name="Hans", last_name="Müller", line1="Example, Inc.", # Jungholz is a VAT exception area where German, not # Austrian, VAT rates apply line4="Jungholz", # Correct postcode for Jungholz postcode="6691", # Incorrect area code (valid number, but uses Graz area # code) phone_number="+43 316 1234567", country=self.at.iso_3166_1_a2, ) form = UserAddressForm(self.hansmueller, data) self.assertFalse(form.is_valid())
def test_empty_address(self): data = dict(user=self.johndoe) form = UserAddressForm(self.johndoe, data) self.assertFalse(form.is_valid())