Beispiel #1
0
 def test_multiple(self):
     obj = MultiCountry(countries="AU,NZ")
     self.assertEqual(len(obj.countries), 2)
     for country in obj.countries:
         self.assertTrue(isinstance(country, fields.Country))
     self.assertEqual(obj.countries[0], "AU")
     self.assertEqual(obj.countries[1], "NZ")
Beispiel #2
0
 def test_validate_multiple_invalid(self):
     person = MultiCountry(countries=[":(", "AU"])
     self.assertRaises(validators.ValidationError, person.full_clean)
Beispiel #3
0
 def test_validate_multiple_empty(self):
     person = MultiCountry()
     self.assertRaises(validators.ValidationError, person.full_clean)
 def test_validate_multiple_uneditable(self):
     person = MultiCountry(countries="NZ", uneditable_countries="xx")
     person.full_clean()
Beispiel #5
0
 def test_multi_serialize(self):
     mc = MultiCountry(countries="NZ,AU")
     serializer = MultiCountrySerializer(mc)
     self.assertEqual(serializer.data, {"countries": ["NZ", "AU"]})
Beispiel #6
0
 def test_set_country(self):
     obj = MultiCountry()
     obj.countries = fields.Country("NZ")
     self.assertEqual(obj.countries, ["NZ"])
Beispiel #7
0
 def test_set_text(self):
     obj = MultiCountry()
     obj.countries = "NZ,AU"
     self.assertEqual(obj.countries, ["NZ", "AU"])
Beispiel #8
0
 def test_single(self):
     obj = MultiCountry(countries="NZ")
     self.assertEqual(len(obj.countries), 1)
     self.assertTrue(isinstance(obj.countries[0], fields.Country))
     self.assertEqual(obj.countries[0], "NZ")
Beispiel #9
0
 def test_validate_multiple_uneditable(self):
     person = MultiCountry(countries='NZ', uneditable_countries='xx')
     person.full_clean()
Beispiel #10
0
 def test_validate_multiple(self):
     person = MultiCountry(countries=['NZ', 'AU'])
     person.full_clean()
Beispiel #11
0
 def test_multi_serialize(self):
     mc = MultiCountry(countries='NZ,AU')
     serializer = MultiCountrySerializer(mc)
     self.assertEqual(serializer.data, {'countries': ['NZ', 'AU']})
 def test_set_countries(self):
     obj = MultiCountry()
     obj.countries = [fields.Country("NZ"), fields.Country("AU")]
     self.assertEqual(obj.countries, ["NZ", "AU"])
 def test_set_country(self):
     obj = MultiCountry()
     obj.countries = fields.Country("NZ")
     self.assertEqual(obj.countries, ["NZ"])
 def test_set_list(self):
     obj = MultiCountry()
     obj.countries = ["NZ", "AU"]
     self.assertEqual(obj.countries, ["NZ", "AU"])
 def test_set_text(self):
     obj = MultiCountry()
     obj.countries = "NZ,AU"
     self.assertEqual(obj.countries, ["NZ", "AU"])
Beispiel #16
0
 def test_validate_multiple_uneditable(self):
     person = MultiCountry(countries="NZ", uneditable_countries="xx")
     person.full_clean()
Beispiel #17
0
 def test_empty(self):
     obj = MultiCountry()
     self.assertEqual(obj.countries, [])
Beispiel #18
0
 def test_set_text(self):
     obj = MultiCountry()
     obj.countries = 'NZ,AU'
     self.assertEqual(obj.countries, ['NZ', 'AU'])
Beispiel #19
0
 def test_set_list(self):
     obj = MultiCountry()
     obj.countries = ['NZ', 'AU']
     self.assertEqual(obj.countries, ['NZ', 'AU'])
Beispiel #20
0
 def test_set_country(self):
     obj = MultiCountry()
     obj.countries = fields.Country('NZ')
     self.assertEqual(obj.countries, ['NZ'])
Beispiel #21
0
 def test_set_list(self):
     obj = MultiCountry()
     obj.countries = ["NZ", "AU"]
     self.assertEqual(obj.countries, ["NZ", "AU"])
Beispiel #22
0
 def test_set_countries(self):
     obj = MultiCountry()
     obj.countries = [fields.Country('NZ'), fields.Country('AU')]
     self.assertEqual(obj.countries, ['NZ', 'AU'])
Beispiel #23
0
 def test_set_countries(self):
     obj = MultiCountry()
     obj.countries = [fields.Country("NZ"), fields.Country("AU")]
     self.assertEqual(obj.countries, ["NZ", "AU"])
Beispiel #24
0
 def test_validate_multiple(self):
     person = MultiCountry(countries=["NZ", "AU"])
     person.full_clean()
Beispiel #25
0
 def test_multi_serialize_empty(self):
     mc = MultiCountry(countries="")
     serializer = MultiCountrySerializer(mc)
     self.assertEqual(serializer.data, {"countries": []})
 def test_validate_multiple(self):
     person = MultiCountry(countries=["NZ", "AU"])
     person.full_clean()