Exemplo n.º 1
0
 def test_local_phonenumber_invalid_without_country(self):
     # Add another country, so we have two.
     CountryFactory(iso_3166_1_a2='DE', is_shipping_country=True)
     data = self.minimal_data.copy()
     data['phone_number'] = '07 914721389'
     # User hasn't selected a country. Because there are multiple country
     # choices we should not accept the local number.
     form = ShippingAddressForm(data)
     self.assertFalse(form.is_valid())
     self.assertIn('phone_number', form.errors)
Exemplo n.º 2
0
 def test_local_phonenumber_invalid_without_country(self):
     # Add another country, so we have two.
     CountryFactory(iso_3166_1_a2='DE', is_shipping_country=True)
     data = self.minimal_data.copy()
     data['phone_number'] = '07 914721389'
     # User hasn't selected a country. Because there are multiple country
     # choices we should not accept the local number.
     form = ShippingAddressForm(data)
     self.assertFalse(form.is_valid())
     self.assertIn('phone_number', form.errors)
def get_address_fields():
    def new_init(self, *args, **kwargs):
        super(ShippingAddressForm, self).__init__(*args, **kwargs)

    ShippingAddressForm.__init__ = new_init

    data = {
        'first_name': 'John',
        'last_name': 'Doe',
        'line1': '1 Egg Road',
        'line4': 'Shell City',
        'postcode': 'N12 9RT',
        'phone_number': '+49231555555',
    }

    form = ShippingAddressForm(data)
    form.is_valid()
    address_fields = dict((k, v) for (k, v) in form.instance.__dict__.items()
                          if not k.startswith('_'))
    return address_fields
def get_address_fields():
    def new_init(self, *args, **kwargs):
        super(ShippingAddressForm, self).__init__(*args, **kwargs)

    ShippingAddressForm.__init__ = new_init

    data = {
        'first_name': 'John',
        'last_name': 'Doe',
        'line1': '1 Egg Road',
        'line4': 'Shell City',
        'postcode': 'N12 9RT',
        'phone_number': '+49231555555',
    }

    form = ShippingAddressForm(data)
    form.is_valid()
    address_fields = dict(
        (k, v) for (k, v) in form.instance.__dict__.items()
        if not k.startswith('_'))
    return address_fields
Exemplo n.º 5
0
 def test_is_valid_with_international_phone_number(self):
     data = self.minimal_data.copy()
     data['phone_number'] = '+49 176 968426 71'
     form = ShippingAddressForm(data)
     self.assertTrue(form.is_valid())
Exemplo n.º 6
0
 def test_is_valid_with_international_phone_number(self):
     data = self.minimal_data.copy()
     data['phone_number'] = '+49 176 968426 71'
     form = ShippingAddressForm(data)
     self.assertTrue(form.is_valid())