@@ -55,6 +55,43 @@ def test_read_sort(self):
5555 for record_id in record_ids :
5656 self .jb .delete (box_id , record_id )
5757
58+ def test_read_limit (self ):
59+ data = [{"name" : "first" , "age" : "25" }, {"name" : "second" , "age" : "19" }]
60+ box_id = TEST_BOX_ID + "_limit"
61+ result = self .jb .write (data , box_id )
62+ record_ids = self .jb .get_record_id (result )
63+
64+ json_data = self .jb .read (box_id , limit = 1 )
65+ self .assertIsNotNone (json_data )
66+ self .assertTrue (isinstance (json_data , list ))
67+ self .assertEqual (len (json_data ), 1 )
68+
69+ # cleanup
70+ for record_id in record_ids :
71+ self .jb .delete (box_id , record_id )
72+
73+ def test_read_query (self ):
74+ data = [{"name" : "first" , "age" : 25 }, {"name" : "second" , "age" : 19 }]
75+ box_id = TEST_BOX_ID + "_query"
76+ result = self .jb .write (data , box_id )
77+ record_ids = self .jb .get_record_id (result )
78+
79+ json_data = self .jb .read (box_id , query = "name:firs*" )
80+ self .assertIsNotNone (json_data )
81+ self .assertTrue (isinstance (json_data , list ))
82+ self .assertEqual (len (json_data ), 1 )
83+ self .assertEqual (json_data [0 ]["name" ], "first" )
84+
85+ json_data = self .jb .read (box_id , query = "age:=19" )
86+ self .assertIsNotNone (json_data )
87+ self .assertTrue (isinstance (json_data , list ))
88+ self .assertEqual (len (json_data ), 1 )
89+ self .assertEqual (json_data [0 ]["name" ], "second" )
90+
91+ # cleanup
92+ for record_id in record_ids :
93+ self .jb .delete (box_id , record_id )
94+
5895 def test_write_box (self ):
5996 data = {
6097 TEST_DATA_KEY_1 : TEST_DATA_VALUE_1
0 commit comments