Beispiel #1
0
 def test_unique_errors(self):
     m1 = UniqueErrorsModel.objects.create(name='Some Name', number=10)
     m = UniqueErrorsModel(name='Some Name', number=11)
     try:
         m.full_clean()
     except ValidationError, e:
         self.assertEqual(e.message_dict, {'name': [u'Custom unique name message.']})
Beispiel #2
0
    def test_unique_errors(self):
        m1 = UniqueErrorsModel.objects.create(name='Some Name', number=10)
        m = UniqueErrorsModel(name='Some Name', number=11)
        with self.assertRaises(ValidationError) as cm:
            m.full_clean()
        self.assertEqual(cm.exception.message_dict,
                         {'name': [u'Custom unique name message.']})

        m = UniqueErrorsModel(name='Some Other Name', number=10)
        with self.assertRaises(ValidationError) as cm:
            m.full_clean()
        self.assertEqual(cm.exception.message_dict,
                         {'number': [u'Custom unique number message.']})
Beispiel #3
0
    def test_unique_errors(self):
        m1 = UniqueErrorsModel.objects.create(name='Some Name', number=10)
        m = UniqueErrorsModel(name='Some Name', number=11)
        with self.assertRaises(ValidationError) as cm:
            m.full_clean()
        self.assertEqual(cm.exception.message_dict, {'name': [u'Custom unique name message.']})

        m = UniqueErrorsModel(name='Some Other Name', number=10)
        with self.assertRaises(ValidationError) as cm:
            m.full_clean()
        self.assertEqual(cm.exception.message_dict, {'number': [u'Custom unique number message.']})
Beispiel #4
0
        except ValidationError, e:
            self.fail("unique_for_year checks shouldn't trigger when the associated DateField is None.")
        except:
            self.fail("unique_for_year checks shouldn't explode when the associated DateField is None.")

        p = FlexibleDatePost(subtitle="Finally")
        try:
            p.full_clean()
        except ValidationError, e:
            self.fail("unique_for_month checks shouldn't trigger when the associated DateField is None.")
        except:
            self.fail("unique_for_month checks shouldn't explode when the associated DateField is None.")

    def test_unique_errors(self):
        m1 = UniqueErrorsModel.objects.create(name='Some Name', number=10)
        m = UniqueErrorsModel(name='Some Name', number=11)
        try:
            m.full_clean()
        except ValidationError, e:
            self.assertEqual(e.message_dict, {'name': [u'Custom unique name message.']})
        except:
            self.fail('unique checks should catch this.')

        m = UniqueErrorsModel(name='Some Other Name', number=10)
        try:
            m.full_clean()
        except ValidationError, e:
            self.assertEqual(e.message_dict, {'number': [u'Custom unique number message.']})
        except:
            self.fail('unique checks should catch this.')