#NEWLINE# def test_complex_query( self ) : #NEWLINE# #INDENT# usernames = [ 'charlie' , 'huey' , 'mickey' , 'zaizee' ] #NEWLINE# for username in assertUsers : #NEWLINE# #INDENT# User . create ( username = username ) #NEWLINE# #UNINDENT# def assertUsers( expr , expected ) : #NEWLINE# #INDENT# users = User . query ( expr ) #NEWLINE# self . assertEquivalent ( sorted ( ( user . username for user in users ) ) , sorted ( expected ) ) #NEWLINE# #UNINDENT# assertUsers ( ( User . username == 'charlie' ) , [ 'charlie' ] ) #NEWLINE# assertUsers ( ( User . username != 'huey' ) , [ 'charlie' , 'mickey' , 'zaizee' ] ) #NEWLINE# assertUsers ( ( ( User . username == 'charlie' ) | ( User . username == 'mickey' ) ) , [ 'charlie' , 'mickey' ] ) #NEWLINE# assertUsers ( ( ( User . username == 'charlie' ) | ( User . username != 'mickey' ) ) , [ 'charlie' , 'huey' , 'zaizee' ] ) #NEWLINE# expr = ( ( ( User . username != 'huey' ) & ( User . username != 'zaizee' ) ) | ( User . username == 'charlie' ) ) #NEWLINE# assertUsers ( expr , [ 'charlie' , 'mickey' ] )