<s> from couchbase . tests . base import ConnectionTestCase <EOL> INT_TYPES = None <EOL> try : <EOL> INT_TYPES = ( long , int ) <EOL> except : <EOL> INT_TYPES = ( int , ) <EOL> class ResultsTest ( ConnectionTestCase ) : <EOL> def __test_oprsesult ( self , rv , check_exact = True , exprc = <NUM_LIT:0> ) : <EOL> self . assertIsInstance ( rv , self . cls_OperationResult ) <EOL> self . assertIsInstance ( rv , self . cls_Result ) <EOL> if check_exact : <EOL> self . assertEqual ( rv . __class__ , self . cls_OperationResult ) <EOL> self . assertIsInstance ( rv . cas , INT_TYPES ) <EOL> self . assertIsInstance ( rv . rc , INT_TYPES ) <EOL> self . assertEqual ( rv . rc , exprc ) <EOL> if exprc == <NUM_LIT:0> : <EOL> self . assertTrue ( rv . success ) <EOL> self . assertIsInstance ( rv . errstr , str ) <EOL> self . assertIsInstance ( repr ( rv ) , str ) <EOL> self . assertIsInstance ( str ( rv ) , str ) <EOL> def __test_valresult ( self , rv , value ) : <EOL> self . assertEqual ( rv . __class__ , self . cls_ValueResult ) <EOL> self . __test_oprsesult ( rv , check_exact = False ) <EOL> self . assertEqual ( rv . value , value ) <EOL> self . assertIsInstance ( rv . flags , INT_TYPES ) <EOL> def test_results ( self ) : <EOL> key = self . gen_key ( "<STR_LIT>" ) <EOL> rv = self . cb . upsert ( key , "<STR_LIT:value>" ) <EOL> self . __test_oprsesult ( rv ) <EOL> rv = self . cb . remove ( key ) <EOL> self . __test_oprsesult ( rv ) <EOL> rv = self . cb . upsert ( key , "<STR_LIT:value>" ) <EOL> self . __test_oprsesult ( rv ) <EOL> rv = self . cb . lock ( key , ttl = <NUM_LIT:10> ) <EOL> self . __test_valresult ( rv , "<STR_LIT:value>" ) <EOL> rv = self . cb . unlock ( key , rv . cas ) <EOL> self . __test_oprsesult ( rv ) <EOL> rv = self . cb . get ( key ) <EOL> self . __test_valresult ( rv , "<STR_LIT:value>" ) <EOL> rv = self . cb . remove ( key ) <EOL> self . __test_oprsesult ( rv ) <EOL> rv = self . cb . counter ( key , initial = <NUM_LIT:10> ) <EOL> self . __test_valresult ( rv , <NUM_LIT:10> ) <EOL> rv = self . cb . get ( key ) <EOL> self . __test_valresult ( rv , <NUM_LIT:10> ) <EOL> rv = self . cb . touch ( key ) <EOL> self . __test_oprsesult ( rv ) <EOL> def test_multi_results ( self ) : <EOL> kvs = self . gen_kv_dict ( prefix = "<STR_LIT>" ) <EOL> rvs = self . cb . upsert_multi ( kvs ) <EOL> self . assertIsInstance ( rvs , self . cls_MultiResult ) <EOL> [ self . __test_oprsesult ( x ) for x in rvs . values ( ) ] <EOL> repr ( rvs ) <EOL> str ( rvs ) <EOL> rvs = self . cb . get_multi ( kvs . keys ( ) ) <EOL> self . assertIsInstance ( rvs , self . cls_MultiResult ) <EOL> self . assertTrue ( rvs . all_ok ) <EOL> [ self . __test_valresult ( v , kvs [ k ] ) for k , v in rvs . items ( ) ] <EOL> rvs = self . cb . remove_multi ( kvs . keys ( ) ) <EOL> [ self . __test_oprsesult ( x ) for x in rvs . values ( ) ] </s>
