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')
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')
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()