#NEWLINE# def test_lookup_in( self ) : #NEWLINE# #INDENT# cb = self . cb #NEWLINE# key = self . gen_key ( 'sdget' ) #NEWLINE# cb . upsert ( key , { #NEWLINE# #INDENT# 'path1' : 'value1' , #NEWLINE# #UNINDENT# } ) #NEWLINE# result = cb . retrieve_in ( key , 'path1' ) #NEWLINE# self . assertEqual ( ( 0 , 'value1' ) , result . get ( 0 ) ) #NEWLINE# self . assertEqual ( ( 0 , 'value1' ) , result . get ( 'path1' ) ) #NEWLINE# self . assertEqual ( 'value1' , result [ 0 ] ) #NEWLINE# self . assertEqual ( 'value1' , result [ 'path1' ] ) #NEWLINE# self . assertTrue ( result . cas ) #NEWLINE# rv = cb . retrieve_in ( key , 'path2' ) #NEWLINE# self . assertEqual ( E . SubdocMultipleErrors . CODE , rv . rc ) #NEWLINE# self . assertEqual ( E . SubdocPathNotFoundError . CODE , rv . get ( 0 ) [ 0 ] ) #NEWLINE# self . assertRaises ( E . SubdocPathNotFoundError , rv . __getitem__ , 0 ) #NEWLINE# self . assertRaises ( E . SubdocPathNotFoundError , rv . __getitem__ , 'path2' ) #NEWLINE# self . assertRaises ( E . SubdocPathMismatchError , cb . retrieve_in , key , 'path1[0]' ) #NEWLINE# result = cb . lookup_in ( key , SD . exists ( 'path1' ) ) #NEWLINE# self . assertTrue ( result . exists ( 'path1' ) ) #NEWLINE# self . assertTrue ( result . exists ( 0 ) ) #NEWLINE# result = cb . lookup_in ( key , SD . exists ( 'p' ) ) #NEWLINE# self . assertEqual ( E . SubdocMultipleErrors . CODE , result . rc ) #NEWLINE# self . assertEqual ( E . SubdocPathNotFoundError . CODE , result . get ( 0 ) [ 0 ] ) #NEWLINE# result = cb . lookup_in ( key , SD . exists ( 'p' ) , quiet = True ) #NEWLINE# self . assertFalse ( result . exists ( 'p' ) ) #NEWLINE# self . assertFalse ( result . exists ( 0 ) ) #NEWLINE# bkey = self . gen_key ( 'sdget_nonjson' ) #NEWLINE# cb . upsert ( bkey , 'value' , format = FMT_UTF8 ) #NEWLINE# self . assertRaises ( E . DocumentNotJsonError , cb . lookup_in , bkey , SD . exists ( 'path' ) ) #NEWLINE# self . assertRaises ( E . InvalidError , cb . retrieve_in , key , '' ) #NEWLINE# self . assertRaises ( E . NotFoundError , cb . retrieve_in , 'non-exist' , 'path' )