Exemplo n.º 1
0
 def test_set_countries(self):
     obj = MultiCountry()
     obj.countries = [fields.Country("NZ"), fields.Country("AU")]
     self.assertEqual(obj.countries, ["NZ", "AU"])
Exemplo n.º 2
0
 def test_empty_flag_url(self):
     country = fields.Country(code='XX', flag_url='')
     self.assertEqual(country.flag, '')
Exemplo n.º 3
0
 def test_set_countries(self):
     obj = MultiCountry()
     obj.countries = [fields.Country('NZ'), fields.Country('AU')]
     self.assertEqual(obj.countries, ['NZ', 'AU'])
Exemplo n.º 4
0
 def test_alpha3(self):
     country = fields.Country(code='BN')
     self.assertEqual(country.alpha3, 'BRN')
Exemplo n.º 5
0
 def test_numeric(self):
     country = fields.Country(code='BN')
     self.assertEqual(country.numeric, 96)
Exemplo n.º 6
0
 def test_str(self):
     country = fields.Country(code='NZ')
     self.assertEqual('%s' % country, 'NZ')
Exemplo n.º 7
0
 def test_ioc_code(self):
     country = fields.Country(code='NL', flag_url='')
     self.assertEqual(country.ioc_code, 'NED')
Exemplo n.º 8
0
 def test_alpha3(self):
     country = fields.Country(code="BN")
     self.assertEqual(country.alpha3, "BRN")
Exemplo n.º 9
0
 def test_alpha3_invalid(self):
     country = fields.Country(code="XX")
     self.assertEqual(country.alpha3, "")
Exemplo n.º 10
0
 def test_ioc_code(self):
     country = fields.Country(code="NL", flag_url="")
     self.assertEqual(country.ioc_code, "NED")
Exemplo n.º 11
0
 def test_country_from_ioc_code(self):
     country = fields.Country.country_from_ioc("NED")
     self.assertEqual(country, fields.Country("NL", flag_url=""))
Exemplo n.º 12
0
 def test_str_attr(self):
     country = fields.Country(code="NZ", str_attr="name")
     self.assertEqual("%s" % country, "New Zealand")
Exemplo n.º 13
0
 def test_str(self):
     country = fields.Country(code="NZ")
     self.assertEqual("%s" % country, "NZ")
Exemplo n.º 14
0
 def test_hash(self):
     country = fields.Country(code="XX", flag_url="")
     self.assertEqual(hash(country), hash("XX"))
Exemplo n.º 15
0
 def test_numeric_code_invalid(self):
     country = fields.Country(code=999)
     self.assertEqual(country.code, 999)
Exemplo n.º 16
0
 def test_numeric_invalid(self):
     country = fields.Country(code="XX")
     self.assertEqual(country.numeric, None)
Exemplo n.º 17
0
 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)
Exemplo n.º 18
0
 def test_empty_flag_url(self):
     country = fields.Country(code="XX", flag_url="")
     self.assertEqual(country.flag, "")
Exemplo n.º 19
0
 def test_str_attr(self):
     country = fields.Country(code='NZ', str_attr='name')
     self.assertEqual('%s' % country, 'New Zealand')
Exemplo n.º 20
0
 def test_alpha2_code(self):
     country = fields.Country(code="NZL")
     self.assertEqual(country.code, "NZ")
Exemplo n.º 21
0
 def test_country_from_ioc_code(self):
     country = fields.Country.country_from_ioc('NED')
     self.assertEqual(country, fields.Country('NL', flag_url=''))
Exemplo n.º 22
0
 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')
Exemplo n.º 23
0
 def test_alpha3_invalid(self):
     country = fields.Country(code='XX')
     self.assertEqual(country.alpha3, '')
Exemplo n.º 24
0
 def test_alpha2_code(self):
     country = fields.Country(code='NZL')
     self.assertEqual(country.code, 'NZ')
Exemplo n.º 25
0
 def test_numeric_padded_invalid(self):
     country = fields.Country(code='XX')
     self.assertEqual(country.numeric_padded, None)
Exemplo n.º 26
0
 def test_alpha2_code_invalid(self):
     country = fields.Country(code='NZX')
     self.assertEqual(country.code, 'NZX')
Exemplo n.º 27
0
 def test_set_country(self):
     obj = MultiCountry()
     obj.countries = fields.Country('NZ')
     self.assertEqual(obj.countries, ['NZ'])
Exemplo n.º 28
0
 def test_numeric_code(self):
     country = fields.Country(code=554)
     self.assertEqual(country.code, 'NZ')
Exemplo n.º 29
0
 def test_hash(self):
     country = fields.Country(code='XX', flag_url='')
     self.assertEqual(hash(country), hash('XX'))
Exemplo n.º 30
0
 def test_set_country(self):
     obj = MultiCountry()
     obj.countries = fields.Country("NZ")
     self.assertEqual(obj.countries, ["NZ"])