#NEWLINE# def test_query_with_update( self ) : #NEWLINE# #INDENT# stat = Stat . create ( stat_type = 's1' , value = 1 ) #NEWLINE# vq = list ( Stat . query ( ( Stat . value == 1 ) ) ) #NEWLINE# self . assertEqual ( len ( vq ) , 1 ) #NEWLINE# stat_db = vq [ 0 ] #NEWLINE# self . assertEquivalent ( stat_db . stat_type , 's1' ) #NEWLINE# self . assertEqual ( stat_db . value , 1 ) #NEWLINE# stat . value = 2 #NEWLINE# stat . save ( ) #NEWLINE# def assertCount( expr , count ) : #NEWLINE# #INDENT# self . assertEqual ( len ( list ( Stat . query ( expr ) ) ) , count ) #NEWLINE# #UNINDENT# assertCount ( ( Stat . value == 1 ) , 0 ) #NEWLINE# assertCount ( ( Stat . value == 2 ) , 1 ) #NEWLINE# assertCount ( ( Stat . stat_type == 's1' ) , 1 ) #NEWLINE# stat . stat_type = 's2' #NEWLINE# stat . save ( ) #NEWLINE# assertCount ( ( Stat . value == 1 ) , 0 ) #NEWLINE# assertCount ( ( Stat . value == 2 ) , 1 ) #NEWLINE# assertCount ( ( Stat . stat_type == 's1' ) , 0 ) #NEWLINE# assertCount ( ( Stat . stat_type == 's2' ) , 1 )