def test_unique_for_date(self):
        p1 = Post.objects.create(title="Django 1.0 is released",
            slug="Django 1.0", subtitle="Finally", posted=datetime.date(2008, 9, 3))

        p = Post(title="Django 1.0 is released", posted=datetime.date(2008, 9, 3))
        try:
            p.full_clean()
        except ValidationError, e:
            self.assertEqual(e.message_dict, {'title': [u'Title must be unique for Posted date.']})
        else:
            self.fail('unique_for_date checks should catch this.')

        # Should work without errors
        p = Post(title="Work on Django 1.1 begins", posted=datetime.date(2008, 9, 3))
        p.full_clean()

        # Should work without errors
        p = Post(title="Django 1.0 is released", posted=datetime.datetime(2008, 9,4))
        p.full_clean()

        p = Post(slug="Django 1.0", posted=datetime.datetime(2008, 1, 1))
        try:
            p.full_clean()
        except __HOLE__, e:
            self.assertEqual(e.message_dict, {'slug': [u'Slug must be unique for Posted year.']})
        else:
            self.fail('unique_for_year checks should catch this.')

        p = Post(subtitle="Finally", posted=datetime.datetime(2008, 9, 30))
        try:
            p.full_clean()
        except ValidationError, e:
            self.assertEqual(e.message_dict, {'subtitle': [u'Subtitle must be unique for Posted month.']})
        else:
            self.fail('unique_for_month checks should catch this.')

        p = Post(title="Django 1.0 is released")
        try:
            p.full_clean()
        except ValidationError, e:
            self.assertEqual(e.message_dict, {'posted': [u'This field cannot be null.']})
        else:
            self.fail("Model validation shouldn't allow an absent value for a DateField without null=True.")
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.2/tests/modeltests/validation/test_unique.py/PerformUniqueChecksTest.test_unique_for_date