class CouncilChoiceFieldTestCase(TestCase):
    def setUp(self):
        self.field = CouncilChoiceField(required=False)

    def test_none(self):
        self.assertEqual(self.field.clean({'council': None}), None)

    def test_valid(self):
        pt = models.Country.objects.create(name='Portugal')
        d = models.District.objects.create(name='Viseu', country=pt, base_id=1)
        c = models.Council.objects.create(name='Viseu', district=d, base_id=1)

        value = {'council': 'Viseu', 'country': pt, 'district': d.name}
        self.assertEqual(self.field.clean(value), c)
class CouncilChoiceFieldTestCase(TestCase):
    def setUp(self):
        self.field = CouncilChoiceField(required=False)

    def test_none(self):
        self.assertEqual(self.field.clean({'council': None}), None)

    def test_valid(self):
        pt = models.Country.objects.create(name='Portugal')
        d = models.District.objects.create(name='Viseu', country=pt, base_id=1)
        c = models.Council.objects.create(name='Viseu', district=d, base_id=1)

        value = {'council': 'Viseu', 'country': pt, 'district': d.name}
        self.assertEqual(self.field.clean(value), c)
 def setUp(self):
     self.field = CouncilChoiceField(required=False)
 def setUp(self):
     self.field = CouncilChoiceField(required=False)