def test_set_countries(self): obj = MultiCountry() obj.countries = [fields.Country("NZ"), fields.Country("AU")] self.assertEqual(obj.countries, ["NZ", "AU"])
def test_empty_flag_url(self): country = fields.Country(code='XX', flag_url='') self.assertEqual(country.flag, '')
def test_set_countries(self): obj = MultiCountry() obj.countries = [fields.Country('NZ'), fields.Country('AU')] self.assertEqual(obj.countries, ['NZ', 'AU'])
def test_alpha3(self): country = fields.Country(code='BN') self.assertEqual(country.alpha3, 'BRN')
def test_numeric(self): country = fields.Country(code='BN') self.assertEqual(country.numeric, 96)
def test_str(self): country = fields.Country(code='NZ') self.assertEqual('%s' % country, 'NZ')
def test_ioc_code(self): country = fields.Country(code='NL', flag_url='') self.assertEqual(country.ioc_code, 'NED')
def test_alpha3(self): country = fields.Country(code="BN") self.assertEqual(country.alpha3, "BRN")
def test_alpha3_invalid(self): country = fields.Country(code="XX") self.assertEqual(country.alpha3, "")
def test_ioc_code(self): country = fields.Country(code="NL", flag_url="") self.assertEqual(country.ioc_code, "NED")
def test_country_from_ioc_code(self): country = fields.Country.country_from_ioc("NED") self.assertEqual(country, fields.Country("NL", flag_url=""))
def test_str_attr(self): country = fields.Country(code="NZ", str_attr="name") self.assertEqual("%s" % country, "New Zealand")
def test_str(self): country = fields.Country(code="NZ") self.assertEqual("%s" % country, "NZ")
def test_hash(self): country = fields.Country(code="XX", flag_url="") self.assertEqual(hash(country), hash("XX"))
def test_numeric_code_invalid(self): country = fields.Country(code=999) self.assertEqual(country.code, 999)
def test_numeric_invalid(self): country = fields.Country(code="XX") self.assertEqual(country.numeric, None)
def test_render_initial(self): with self.settings(COUNTRIES_ONLY={"AU": "Desert"}): html = self.Form(initial={"country": "AU"}).as_p() self.assertIn(fields.Country("AU").flag, html) self.assertNotIn(fields.Country("__").flag, html)
def test_empty_flag_url(self): country = fields.Country(code="XX", flag_url="") self.assertEqual(country.flag, "")
def test_str_attr(self): country = fields.Country(code='NZ', str_attr='name') self.assertEqual('%s' % country, 'New Zealand')
def test_alpha2_code(self): country = fields.Country(code="NZL") self.assertEqual(country.code, "NZ")
def test_country_from_ioc_code(self): country = fields.Country.country_from_ioc('NED') self.assertEqual(country, fields.Country('NL', flag_url=''))
def test_extensions(self): with mock.patch.object(fields, 'EXTENSIONS', {'codex2': lambda c: c.code * 2}): country = fields.Country(code='NZ') self.assertEqual(country.codex2, 'NZNZ')
def test_alpha3_invalid(self): country = fields.Country(code='XX') self.assertEqual(country.alpha3, '')
def test_alpha2_code(self): country = fields.Country(code='NZL') self.assertEqual(country.code, 'NZ')
def test_numeric_padded_invalid(self): country = fields.Country(code='XX') self.assertEqual(country.numeric_padded, None)
def test_alpha2_code_invalid(self): country = fields.Country(code='NZX') self.assertEqual(country.code, 'NZX')
def test_set_country(self): obj = MultiCountry() obj.countries = fields.Country('NZ') self.assertEqual(obj.countries, ['NZ'])
def test_numeric_code(self): country = fields.Country(code=554) self.assertEqual(country.code, 'NZ')
def test_hash(self): country = fields.Country(code='XX', flag_url='') self.assertEqual(hash(country), hash('XX'))
def test_set_country(self): obj = MultiCountry() obj.countries = fields.Country("NZ") self.assertEqual(obj.countries, ["NZ"])