#NEWLINE# def test_basic_queries( self ) : #NEWLINE# #INDENT# 'Queries are constrained to a single database' #NEWLINE# dive = Book . objects . using ( 'other' ) . create ( title = 'Dive into Python' , published = datetime . date ( 2009 , 5 , 4 ) ) #NEWLINE# dive = Book . objects . using ( 'other' ) . get ( published = datetime . date ( 2009 , 5 , 4 ) ) #NEWLINE# self . assertEqual ( dive . title , 'Dive into Python' ) #NEWLINE# with self . assertRaises ( Book . DoesNotExist ) : #NEWLINE# #INDENT# Book . objects . using ( 'default' ) . get ( published = datetime . date ( 2009 , 5 , 4 ) ) #NEWLINE# #UNINDENT# dive = Book . objects . using ( 'other' ) . get ( title__icontains = 'dive' ) #NEWLINE# self . assertEqual ( dive . title , 'Dive into Python' ) #NEWLINE# with self . assertRaises ( Book . DoesNotExist ) : #NEWLINE# #INDENT# Book . objects . using ( 'default' ) . get ( title__icontains = 'dive' ) #NEWLINE# #UNINDENT# dive = Book . objects . using ( 'other' ) . get ( title__iexact = 'dive INTO python' ) #NEWLINE# self . assertEqual ( dive . title , 'Dive into Python' ) #NEWLINE# with self . assertRaises ( Book . DoesNotExist ) : #NEWLINE# #INDENT# Book . objects . using ( 'default' ) . get ( title__iexact = 'dive INTO python' ) #NEWLINE# #UNINDENT# dive = Book . objects . using ( 'other' ) . get ( published__year = 2009 ) #NEWLINE# self . assertEqual ( dive . title , 'Dive into Python' ) #NEWLINE# self . assertEqual ( o . published , datetime . date ( 2009 , 5 , 4 ) ) #NEWLINE# with self . assertRaises ( Book . DoesNotExist ) : #NEWLINE# #INDENT# Book . objects . using ( 'default' ) . get ( published__year = 2009 ) #NEWLINE# #UNINDENT# years = Book . objects . using ( 'other' ) . dates ( 'published' , 'year' ) #NEWLINE# self . assertEqual ( [ o . year for o in years ] , [ 2009 ] ) #NEWLINE# years = Book . objects . using ( 'default' ) . dates ( 'published' , 'year' ) #NEWLINE# self . assertEqual ( [ o . year for o in years ] , [ ] ) #NEWLINE# months = Book . objects . using ( 'other' ) . dates ( 'published' , 'month' ) #NEWLINE# self . assertEqual ( [ o . month for o in months ] , [ 5 ] ) #NEWLINE# months = Book . objects . using ( 'default' ) . dates ( 'published' , 'month' ) #NEWLINE# self . assertEqual ( [ o . month for o in months ] , [ ] )