class CountryChoiceFieldTestCase(TestCase):
    def setUp(self):
        self.field = CountryChoiceField(required=False)

    def test_none(self):
        self.assertEqual(self.field.clean('Não definido.'), None)

    def test_valid(self):
        pt = models.Country.objects.create(name='Portugal')
        de = models.Country.objects.create(name='Alemanha')

        self.assertEqual(self.field.clean('Portugal'), pt)
        self.assertEqual(self.field.clean('Alemanha'), de)

    def test_invalid(self):
        self.assertRaises(ValidationError, self.field.clean, 'Non-country')
예제 #2
0
class CountryChoiceFieldTestCase(TestCase):
    def setUp(self):
        crawler = ContractsStaticDataCrawler()
        crawler.retrieve_and_save_countries()

        self.field = CountryChoiceField(required=False)

    def test_none(self):
        self.assertEqual(self.field.clean('Não definido.'), None)

    def test_valid(self):
        self.assertEqual(self.field.clean('Portugal'), models.Country.objects.get(name='Portugal'))
        self.assertEqual(self.field.clean('Alemanha'), models.Country.objects.get(name='Alemanha'))

    def test_invalid(self):
        self.assertRaises(ValidationError, self.field.clean, 'Non-country')
class CountryChoiceFieldTestCase(TestCase):
    def setUp(self):
        self.field = CountryChoiceField(required=False)

    def test_none(self):
        self.assertEqual(self.field.clean('Não definido.'), None)

    def test_valid(self):
        pt = models.Country.objects.create(name='Portugal')
        de = models.Country.objects.create(name='Alemanha')

        self.assertEqual(self.field.clean('Portugal'), pt)
        self.assertEqual(self.field.clean('Alemanha'), de)

    def test_invalid(self):
        self.assertRaises(ValidationError, self.field.clean, 'Non-country')
 def setUp(self):
     self.field = CountryChoiceField(required=False)
예제 #5
0
    def setUp(self):
        crawler = ContractsStaticDataCrawler()
        crawler.retrieve_and_save_countries()

        self.field = CountryChoiceField(required=False)
 def setUp(self):
     self.field = CountryChoiceField(required=False)