11import redis
22from unittest import TestCase
3- from rejson import ReJSONClient , Path
3+ from rejson import Client , Path
44
55class ReJSONTestCase (TestCase ):
66 def testJSONSetGetDelShouldSucceed (self ):
77 "Test basic JSONSet/Get/Del"
8- rj = ReJSONClient ()
8+ rj = Client ()
99 rj .flushdb ()
1010
1111 self .assertTrue (rj .JSONSet ('foo' , Path .rootPath (), 'bar' ))
@@ -15,7 +15,7 @@ def testJSONSetGetDelShouldSucceed(self):
1515
1616 def testMGetShouldSucceed (self ):
1717 "Test JSONMGet"
18- rj = ReJSONClient ()
18+ rj = Client ()
1919 rj .flushdb ()
2020
2121 rj .JSONSet ('1' , Path .rootPath (), 1 )
@@ -26,15 +26,15 @@ def testMGetShouldSucceed(self):
2626
2727 def testTypeShouldSucceed (self ):
2828 "Test JSONType"
29- rj = ReJSONClient ()
29+ rj = Client ()
3030 rj .flushdb ()
3131
3232 rj .JSONSet ('1' , Path .rootPath (), 1 )
3333 self .assertEqual ('integer' , rj .JSONType ('1' ))
3434
3535 def testNumIncrByShouldSucceed (self ):
3636 "Test JSONNumIncrBy"
37- rj = ReJSONClient ()
37+ rj = Client ()
3838 rj .flushdb ()
3939
4040 rj .JSONSet ('num' , Path .rootPath (), 1 )
@@ -44,7 +44,7 @@ def testNumIncrByShouldSucceed(self):
4444
4545 def testNumMultByShouldSucceed (self ):
4646 "Test JSONNumIncrBy"
47- rj = ReJSONClient ()
47+ rj = Client ()
4848 rj .flushdb ()
4949
5050 rj .JSONSet ('num' , Path .rootPath (), 1 )
@@ -54,7 +54,7 @@ def testNumMultByShouldSucceed(self):
5454
5555 def testStrAppendShouldSucceed (self ):
5656 "Test JSONStrAppend"
57- rj = ReJSONClient ()
57+ rj = Client ()
5858 rj .flushdb ()
5959
6060 rj .JSONSet ('str' , Path .rootPath (), 'foo' )
@@ -63,7 +63,7 @@ def testStrAppendShouldSucceed(self):
6363
6464 def testStrLenShouldSucceed (self ):
6565 "Test JSONStrLen"
66- rj = ReJSONClient ()
66+ rj = Client ()
6767 rj .flushdb ()
6868
6969 rj .JSONSet ('str' , Path .rootPath (), 'foo' )
@@ -73,15 +73,15 @@ def testStrLenShouldSucceed(self):
7373
7474 def testArrAppendShouldSucceed (self ):
7575 "Test JSONSArrAppend"
76- rj = ReJSONClient ()
76+ rj = Client ()
7777 rj .flushdb ()
7878
7979 rj .JSONSet ('arr' , Path .rootPath (), [1 ])
8080 self .assertEqual (2 , rj .JSONArrAppend ('arr' , Path .rootPath (), 2 ))
8181
8282 def testArrIndexShouldSucceed (self ):
8383 "Test JSONSArrIndex"
84- rj = ReJSONClient ()
84+ rj = Client ()
8585 rj .flushdb ()
8686
8787 rj .JSONSet ('arr' , Path .rootPath (), [0 , 1 , 2 , 3 , 4 ])
@@ -90,7 +90,7 @@ def testArrIndexShouldSucceed(self):
9090
9191 def testArrInsertShouldSucceed (self ):
9292 "Test JSONSArrInsert"
93- rj = ReJSONClient ()
93+ rj = Client ()
9494 rj .flushdb ()
9595
9696 rj .JSONSet ('arr' , Path .rootPath (), [0 , 4 ])
@@ -99,15 +99,15 @@ def testArrInsertShouldSucceed(self):
9999
100100 def testArrLenShouldSucceed (self ):
101101 "Test JSONSArrLen"
102- rj = ReJSONClient ()
102+ rj = Client ()
103103 rj .flushdb ()
104104
105105 rj .JSONSet ('arr' , Path .rootPath (), [0 , 1 , 2 , 3 , 4 ])
106106 self .assertEqual (5 , rj .JSONArrLen ('arr' , Path .rootPath ()))
107107
108108 def testArrPopShouldSucceed (self ):
109109 "Test JSONSArrPop"
110- rj = ReJSONClient ()
110+ rj = Client ()
111111 rj .flushdb ()
112112
113113 rj .JSONSet ('arr' , Path .rootPath (), [0 , 1 , 2 , 3 , 4 ])
@@ -119,7 +119,7 @@ def testArrPopShouldSucceed(self):
119119
120120 def testArrTrimShouldSucceed (self ):
121121 "Test JSONSArrPop"
122- rj = ReJSONClient ()
122+ rj = Client ()
123123 rj .flushdb ()
124124
125125 rj .JSONSet ('arr' , Path .rootPath (), [0 , 1 , 2 , 3 , 4 ])
@@ -128,7 +128,7 @@ def testArrTrimShouldSucceed(self):
128128
129129 def testObjKeysShouldSucceed (self ):
130130 "Test JSONSObjKeys"
131- rj = ReJSONClient ()
131+ rj = Client ()
132132 rj .flushdb ()
133133
134134 obj = { 'foo' : 'bar' , 'baz' : 'qaz' }
@@ -141,18 +141,30 @@ def testObjKeysShouldSucceed(self):
141141
142142 def testObjLenShouldSucceed (self ):
143143 "Test JSONSObjLen"
144- rj = ReJSONClient ()
144+ rj = Client ()
145145 rj .flushdb ()
146146
147147 obj = { 'foo' : 'bar' , 'baz' : 'qaz' }
148148 rj .JSONSet ('obj' , Path .rootPath (), obj )
149149 self .assertEqual (len (obj ), rj .JSONObjLen ('obj' , Path .rootPath ()))
150150
151+ def testPipeline (self ):
152+ "Test pipeline"
153+ rj = Client ()
154+ rj .flushdb ()
155+
156+ p = rj .pipeline ()
157+ p .JSONSet ('foo' , Path .rootPath (), 'bar' )
158+ p .JSONGet ('foo' )
159+ p .JSONDel ('foo' )
160+ p .exists ('foo' )
161+ self .assertListEqual ([ True , 'bar' , 1 , False ], p .execute ())
162+
151163 def testUsageExampleShouldSucceed (self ):
152164 "Test the usage example"
153165
154166 # Create a new rejson-py client
155- rj = ReJSONClient (host = 'localhost' , port = 6379 )
167+ rj = Client (host = 'localhost' , port = 6379 )
156168
157169 # Set the key `obj` to some object
158170 obj = {
0 commit comments