Пример #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")
Пример #2
0
 def test_validate_multiple_invalid(self):
     person = MultiCountry(countries=[":(", "AU"])
     self.assertRaises(validators.ValidationError, person.full_clean)
Пример #3
0
 def test_validate_multiple_empty(self):
     person = MultiCountry()
     self.assertRaises(validators.ValidationError, person.full_clean)
Пример #4
0
 def test_validate_multiple_uneditable(self):
     person = MultiCountry(countries="NZ", uneditable_countries="xx")
     person.full_clean()
Пример #5
0
 def test_multi_serialize(self):
     mc = MultiCountry(countries="NZ,AU")
     serializer = MultiCountrySerializer(mc)
     self.assertEqual(serializer.data, {"countries": ["NZ", "AU"]})
Пример #6
0
 def test_set_country(self):
     obj = MultiCountry()
     obj.countries = fields.Country("NZ")
     self.assertEqual(obj.countries, ["NZ"])
Пример #7
0
 def test_set_text(self):
     obj = MultiCountry()
     obj.countries = "NZ,AU"
     self.assertEqual(obj.countries, ["NZ", "AU"])
Пример #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")
Пример #9
0
 def test_validate_multiple_uneditable(self):
     person = MultiCountry(countries='NZ', uneditable_countries='xx')
     person.full_clean()
Пример #10
0
 def test_validate_multiple(self):
     person = MultiCountry(countries=['NZ', 'AU'])
     person.full_clean()
Пример #11
0
 def test_multi_serialize(self):
     mc = MultiCountry(countries='NZ,AU')
     serializer = MultiCountrySerializer(mc)
     self.assertEqual(serializer.data, {'countries': ['NZ', 'AU']})
Пример #12
0
 def test_set_countries(self):
     obj = MultiCountry()
     obj.countries = [fields.Country("NZ"), fields.Country("AU")]
     self.assertEqual(obj.countries, ["NZ", "AU"])
Пример #13
0
 def test_set_country(self):
     obj = MultiCountry()
     obj.countries = fields.Country("NZ")
     self.assertEqual(obj.countries, ["NZ"])
Пример #14
0
 def test_set_list(self):
     obj = MultiCountry()
     obj.countries = ["NZ", "AU"]
     self.assertEqual(obj.countries, ["NZ", "AU"])
Пример #15
0
 def test_set_text(self):
     obj = MultiCountry()
     obj.countries = "NZ,AU"
     self.assertEqual(obj.countries, ["NZ", "AU"])
Пример #16
0
 def test_validate_multiple_uneditable(self):
     person = MultiCountry(countries="NZ", uneditable_countries="xx")
     person.full_clean()
Пример #17
0
 def test_empty(self):
     obj = MultiCountry()
     self.assertEqual(obj.countries, [])
Пример #18
0
 def test_set_text(self):
     obj = MultiCountry()
     obj.countries = 'NZ,AU'
     self.assertEqual(obj.countries, ['NZ', 'AU'])
Пример #19
0
 def test_set_list(self):
     obj = MultiCountry()
     obj.countries = ['NZ', 'AU']
     self.assertEqual(obj.countries, ['NZ', 'AU'])
Пример #20
0
 def test_set_country(self):
     obj = MultiCountry()
     obj.countries = fields.Country('NZ')
     self.assertEqual(obj.countries, ['NZ'])
Пример #21
0
 def test_set_list(self):
     obj = MultiCountry()
     obj.countries = ["NZ", "AU"]
     self.assertEqual(obj.countries, ["NZ", "AU"])
Пример #22
0
 def test_set_countries(self):
     obj = MultiCountry()
     obj.countries = [fields.Country('NZ'), fields.Country('AU')]
     self.assertEqual(obj.countries, ['NZ', 'AU'])
Пример #23
0
 def test_set_countries(self):
     obj = MultiCountry()
     obj.countries = [fields.Country("NZ"), fields.Country("AU")]
     self.assertEqual(obj.countries, ["NZ", "AU"])
Пример #24
0
 def test_validate_multiple(self):
     person = MultiCountry(countries=["NZ", "AU"])
     person.full_clean()
Пример #25
0
 def test_multi_serialize_empty(self):
     mc = MultiCountry(countries="")
     serializer = MultiCountrySerializer(mc)
     self.assertEqual(serializer.data, {"countries": []})
Пример #26
0
 def test_validate_multiple(self):
     person = MultiCountry(countries=["NZ", "AU"])
     person.full_clean()