#NEWLINE# def test_get_or_create( self ) : #NEWLINE# #INDENT# ( inst , created ) = TestModel . objects . get_or_create ( str_ = 'foo' , defaults = { #NEWLINE# #INDENT# 'int_' : 0 , #NEWLINE# 'float_' : 0.1 , #NEWLINE# 'list_' : [ 1 , 2 , 3 ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertTrue ( self ) #NEWLINE# self . assertEquals ( TestModel . objects . count ( ) , 1 ) #NEWLINE# self . assertTrue ( inst . pk ) #NEWLINE# self . assertEquals ( inst . str_ , 'foo' ) #NEWLINE# self . assertEquals ( inst . int_ , 0 ) #NEWLINE# self . assertEquals ( inst . float_ , 0.1 ) #NEWLINE# self . assertEquals ( len ( inst . list_ ) , 3 ) #NEWLINE# self . assertTrue ( ( 1 in inst . list_ ) ) #NEWLINE# self . assertTrue ( ( 2 in inst . list_ ) ) #NEWLINE# self . assertTrue ( ( 3 in inst . list_ ) ) #NEWLINE# ( inst , created ) = TestModel . objects . get_or_create ( str_ = 'foo' , defaults = { #NEWLINE# #INDENT# 'int_' : 1 , #NEWLINE# 'float_' : 1.1 , #NEWLINE# 'list_' : [ 1 ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertFalse ( created ) #NEWLINE# self . assertEquals ( TestModel . objects . count ( ) , 1 ) #NEWLINE# self . assertTrue ( inst . pk ) #NEWLINE# self . assertEquals ( inst . str_ , 'foo' ) #NEWLINE# self . assertEquals ( inst . int_ , 0 ) #NEWLINE# self . assertEquals ( inst . float_ , 0.1 ) #NEWLINE# self . assertTrue ( len ( inst . list_ ) , 3 ) #NEWLINE# self . assertTrue ( ( 1 in inst . list_ ) ) #NEWLINE# self . assertTrue ( ( 2 in inst . list_ ) ) #NEWLINE# self . assertTrue ( ( 3 in inst . list_ ) )