#NEWLINE# @ async_test #NEWLINE# def testScanFilter( self ) : #NEWLINE# #INDENT# items = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for h in xrange ( 2 ) : #NEWLINE# #INDENT# items [ h ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for r in xrange ( 2 ) : #NEWLINE# #INDENT# items [ h ] [ r ] = { #NEWLINE# #INDENT# 'attr1' : ( h + ( r * 2 ) ) , #NEWLINE# 'attr2' : ( 'test-%d' % ( h + r ) ) , #NEWLINE# #UNINDENT# } #NEWLINE# self . _client . PutItem ( 'RangeTest' , key = DBKey ( hash_key = h , range_key = r ) , attributes = items [ h ] [ r ] , callback = None ) #NEWLINE# #UNINDENT# #UNINDENT# def _VerifyScan( scan_filter , exp_keys ) : #NEWLINE# #INDENT# result = self . _client . Scan ( table = 'RangeTest' , callback = None , attributes = [ 'test_hk' , 'test_rk' , 'attr1' , 'attr2' ] , scan_filter = scan_filter ) #NEWLINE# for item in result . items : #NEWLINE# #INDENT# key = ( item [ 'test_hk' ] , item [ 'test_rk' ] ) #NEWLINE# self . assertTrue ( ( key in exp_keys ) ) #NEWLINE# exp_keys . remove ( key ) #NEWLINE# #UNINDENT# self . assertEqual ( len ( exp_keys ) , 0 ) #NEWLINE# #UNINDENT# _VerifyScan ( None , set ( [ ( 0 , 0 ) , ( 0 , 1 ) , ( 1 , 0 ) , ( 1 , 1 ) ] ) ) #NEWLINE# _VerifyScan ( { #NEWLINE# #INDENT# 'attr1' : ScanFilter ( [ 0 ] , 'EQ' ) , #NEWLINE# #UNINDENT# } , set ( [ ( 0 , 0 ) ] ) ) #NEWLINE# _VerifyScan ( { #NEWLINE# #INDENT# 'attr1' : ScanFilter ( [ 0 ] , 'GE' ) , #NEWLINE# #UNINDENT# } , set ( [ ( 0 , 0 ) , ( 0 , 1 ) , ( 1 , 0 ) , ( 1 , 1 ) ] ) ) #NEWLINE# _VerifyScan ( { #NEWLINE# #INDENT# 'attr1' : ScanFilter ( [ 0 ] , 'GT' ) , #NEWLINE# #UNINDENT# } , set ( [ ( 0 , 1 ) , ( 1 , 0 ) , ( 1 , 1 ) ] ) ) #NEWLINE# _VerifyScan ( { #NEWLINE# #INDENT# 'attr1' : ScanFilter ( [ 0 ] , 'EQ' ) , #NEWLINE# 'attr2' : ScanFilter ( [ 'test-0' ] , 'EQ' ) , #NEWLINE# #UNINDENT# } , set ( [ ( 0 , 0 ) ] ) ) #NEWLINE# _VerifyScan ( { #NEWLINE# #INDENT# 'attr1' : ScanFilter ( [ 0 ] , 'EQ' ) , #NEWLINE# 'attr2' : ScanFilter ( [ 'test-1' ] , 'EQ' ) , #NEWLINE# #UNINDENT# } , set ( [ ] ) ) #NEWLINE# self . stop ( )