#NEWLINE# def test_unique_for_date( self ) : #NEWLINE# #INDENT# Post . objects . create ( title = 'Django 1.0 is released' , slug = 'Django 1.0' , subtitle = 'Finally' , posted = datetime . date ( 2008 , 9 , 3 ) ) #NEWLINE# p = Post ( title = 'Django 1.0 is released' , posted = datetime . date ( 2008 , 9 , 3 ) ) #NEWLINE# with self . assertRaises ( ValidationError ) as cm : #NEWLINE# #INDENT# p . full_clean ( ) #NEWLINE# #UNINDENT# self . assertEqual ( cm . exception . message_dict , { #NEWLINE# #INDENT# 'title' : [ 'Title must be unique for Posted date.' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# p = Post ( title = 'Work on Django 1.1 begins' , posted = datetime . date ( 2008 , 9 , 3 ) ) #NEWLINE# p . full_clean ( ) #NEWLINE# p = Post ( title = 'Django 1.0 is released' , posted = datetime . datetime ( 2008 , 9 , 4 ) ) #NEWLINE# p . full_clean ( ) #NEWLINE# p = Post ( slug = 'Django 1.0' , posted = datetime . datetime ( 2008 , 1 , 1 ) ) #NEWLINE# with self . assertRaises ( ValidationError ) as cm : #NEWLINE# #INDENT# p . full_clean ( ) #NEWLINE# #UNINDENT# self . assertEqual ( cm . exception . message_dict , { #NEWLINE# #INDENT# 'slug' : [ 'Slug must be unique for Posted year.' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# p = Post ( subtitle = 'Finally' , posted = datetime . datetime ( 2008 , 9 , 30 ) ) #NEWLINE# with self . assertRaises ( ValidationError ) as cm : #NEWLINE# #INDENT# p . full_clean ( ) #NEWLINE# #UNINDENT# self . assertEqual ( cm . exception . message_dict , { #NEWLINE# #INDENT# 'subtitle' : [ 'Subtitle must be unique for Posted month.' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# p = Post ( title = 'Django 1.0 is released' ) #NEWLINE# with self . assertRaises ( ValidationError ) as cm : #NEWLINE# #INDENT# p . full_clean ( ) #NEWLINE# #UNINDENT# self . assertEqual ( cm . exception . message_dict , { #NEWLINE# #INDENT# 'posted' : [ 'This field cannot be null.' ] , #NEWLINE# #UNINDENT# } )