def test_unique_for_date_with_nullable_date(self): p1 = FlexibleDatePost.objects.create(title="Django 1.0 is released", slug="Django 1.0", subtitle="Finally", posted=datetime.date(2008, 9, 3)) p = FlexibleDatePost(title="Django 1.0 is released") try: p.full_clean() except ValidationError, e: self.fail("unique_for_date checks shouldn't trigger when the associated DateField is None.")
p = FlexibleDatePost(title="Django 1.0 is released") try: p.full_clean() except ValidationError, e: self.fail("unique_for_date checks shouldn't trigger when the associated DateField is None.") p = FlexibleDatePost(slug="Django 1.0") try: p.full_clean() except ValidationError, e: self.fail("unique_for_year checks shouldn't trigger 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.") 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.']})
except ValidationError, e: self.fail( "unique_for_date checks shouldn't trigger when the associated DateField is None." ) p = FlexibleDatePost(slug="Django 1.0") try: p.full_clean() except ValidationError, e: self.fail( "unique_for_year checks shouldn't trigger 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." ) 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: