Exemplo n.º 1
0
    def test_dont_allow_empty(self, product_details):
        product_details.get_regions.return_value = ({'us': 'United States',
                                                     'fr': 'France'})
        with self.settings(INELIGIBLE_COUNTRIES=['us']):
            with self.activate('fr'):
                choices = country_choices(allow_empty=False)

        eq_(choices, [('fr', 'France')])
        product_details.get_regions.assert_called_with('fr')
Exemplo n.º 2
0
    def test_basic(self, product_details):
        product_details.get_regions.return_value = ({'us': 'United States',
                                                     'fr': 'France'})
        with self.settings(INELIGIBLE_COUNTRIES=['fr']):
            with self.activate('en-US'):
                choices = country_choices(allow_empty=True)

        eq_(choices, [('', '---'), ('us', 'United States')])
        product_details.get_regions.assert_called_with('en-us')
Exemplo n.º 3
0
    def __init__(self, *args, **kwargs):
        super(UserProfileForm, self).__init__(*args, **kwargs)

        # Localize countries list
        self.fields['country'].choices = country_choices(allow_empty=False)
        self.fields['mailing_country'].choices = country_choices()