@@ -16,39 +16,39 @@ def setUp(self):
1616self .api = woocommerce .API (
1717url = "http://woo.test" ,
1818consumer_key = self .consumer_key ,
19- consumer_secret = self .consumer_secret
19+ consumer_secret = self .consumer_secret ,
2020 )
2121
2222def test_version (self ):
23- """ Test default version """
23+ """Test default version"""
2424api = woocommerce .API (
2525url = "https://woo.test" ,
2626consumer_key = self .consumer_key ,
27- consumer_secret = self .consumer_secret
27+ consumer_secret = self .consumer_secret ,
2828 )
2929
3030self .assertEqual (api .version ,"wc/v3" )
3131
3232def test_non_ssl (self ):
33- """ Test non-ssl """
33+ """Test non-ssl"""
3434api = woocommerce .API (
3535url = "http://woo.test" ,
3636consumer_key = self .consumer_key ,
37- consumer_secret = self .consumer_secret
37+ consumer_secret = self .consumer_secret ,
3838 )
3939self .assertFalse (api .is_ssl )
4040
4141def test_with_ssl (self ):
42- """ Test ssl """
42+ """Test ssl"""
4343api = woocommerce .API (
4444url = "https://woo.test" ,
4545consumer_key = self .consumer_key ,
46- consumer_secret = self .consumer_secret
46+ consumer_secret = self .consumer_secret ,
4747 )
4848self .assertTrue (api .is_ssl ,True )
4949
5050def test_with_timeout (self ):
51- """ Test timeout """
51+ """Test timeout"""
5252api = woocommerce .API (
5353url = "https://woo.test" ,
5454consumer_key = self .consumer_key ,
@@ -59,105 +59,114 @@ def test_with_timeout(self):
5959
6060@all_requests
6161def woo_test_mock (* args ,** kwargs ):
62- """ URL Mock """
63- return {'status_code' :200 ,
64- 'content' :'OK' }
62+ """URL Mock"""
63+ return {"status_code" :200 ,"content" :"OK" }
6564
6665with HTTMock (woo_test_mock ):
6766# call requests
6867status = api .get ("products" ).status_code
6968self .assertEqual (status ,200 )
7069
7170def test_get (self ):
72- """ Test GET requests """
71+ """Test GET requests"""
72+
7373@all_requests
7474def woo_test_mock (* args ,** kwargs ):
75- """ URL Mock """
76- return {'status_code' :200 ,
77- 'content' :'OK' }
75+ """URL Mock"""
76+ return {"status_code" :200 ,"content" :"OK" }
7877
7978with HTTMock (woo_test_mock ):
8079# call requests
8180status = self .api .get ("products" ).status_code
8281self .assertEqual (status ,200 )
8382
8483def test_get_with_parameters (self ):
85- """ Test GET requests w/ url params """
84+ """Test GET requests w/ url params"""
85+
8686@all_requests
8787def woo_test_mock (* args ,** kwargs ):
88- return {'status_code' :200 ,
89- 'content' :'OK' }
88+ return {"status_code" :200 ,"content" :"OK" }
9089
9190with HTTMock (woo_test_mock ):
9291# call requests
93- status = self .api .get ("products" ,params = {"per_page" :10 ,"page" :1 ,"offset" :0 }).status_code
92+ status = self .api .get (
93+ "products" ,params = {"per_page" :10 ,"page" :1 ,"offset" :0 }
94+ ).status_code
9495self .assertEqual (status ,200 )
9596
9697def test_get_with_requests_kwargs (self ):
97- """ Test GET requests w/ optional requests-module kwargs """
98+ """Test GET requests w/ optional requests-module kwargs"""
9899
99100@all_requests
100101def woo_test_mock (* args ,** kwargs ):
101- return {'status_code' :200 ,
102- 'content' :'OK' }
102+ return {"status_code" :200 ,"content" :"OK" }
103103
104104with HTTMock (woo_test_mock ):
105105# call requests
106106status = self .api .get ("products" ,allow_redirects = True ).status_code
107107self .assertEqual (status ,200 )
108108
109109def test_post (self ):
110- """ Test POST requests """
110+ """Test POST requests"""
111+
111112@all_requests
112113def woo_test_mock (* args ,** kwargs ):
113- """ URL Mock """
114- return {'status_code' :201 ,
115- 'content' :'OK' }
114+ """URL Mock"""
115+ return {"status_code" :201 ,"content" :"OK" }
116116
117117with HTTMock (woo_test_mock ):
118118# call requests
119119status = self .api .post ("products" , {}).status_code
120120self .assertEqual (status ,201 )
121121
122122def test_put (self ):
123- """ Test PUT requests """
123+ """Test PUT requests"""
124+
124125@all_requests
125126def woo_test_mock (* args ,** kwargs ):
126- """ URL Mock """
127- return {'status_code' :200 ,
128- 'content' :'OK' }
127+ """URL Mock"""
128+ return {"status_code" :200 ,"content" :"OK" }
129129
130130with HTTMock (woo_test_mock ):
131131# call requests
132132status = self .api .put ("products" , {}).status_code
133133self .assertEqual (status ,200 )
134134
135135def test_delete (self ):
136- """ Test DELETE requests """
136+ """Test DELETE requests"""
137+
137138@all_requests
138139def woo_test_mock (* args ,** kwargs ):
139- """ URL Mock """
140- return {'status_code' :200 ,
141- 'content' :'OK' }
140+ """URL Mock"""
141+ return {"status_code" :200 ,"content" :"OK" }
142142
143143with HTTMock (woo_test_mock ):
144144# call requests
145145status = self .api .delete ("products" ).status_code
146146self .assertEqual (status ,200 )
147147
148148def test_oauth_sorted_params (self ):
149- """ Test order of parameters for OAuth signature """
149+ """Test order of parameters for OAuth signature"""
150+
150151def check_sorted (keys ,expected ):
151152params = oauth .OrderedDict ()
152153for key in keys :
153- params [key ]= ''
154+ params [key ]= ""
154155
155156ordered = list (oauth .OAuth .sorted_params (params ).keys ())
156157self .assertEqual (ordered ,expected )
157158
158- check_sorted (['a' ,'b' ], ['a' ,'b' ])
159- check_sorted (['b' ,'a' ], ['a' ,'b' ])
160- check_sorted (['a' ,'b[a]' ,'b[b]' ,'b[c]' ,'c' ], ['a' ,'b[a]' ,'b[b]' ,'b[c]' ,'c' ])
161- check_sorted (['a' ,'b[c]' ,'b[a]' ,'b[b]' ,'c' ], ['a' ,'b[c]' ,'b[a]' ,'b[b]' ,'c' ])
162- check_sorted (['d' ,'b[c]' ,'b[a]' ,'b[b]' ,'c' ], ['b[c]' ,'b[a]' ,'b[b]' ,'c' ,'d' ])
163- check_sorted (['a1' ,'b[c]' ,'b[a]' ,'b[b]' ,'a2' ], ['a1' ,'a2' ,'b[c]' ,'b[a]' ,'b[b]' ])
159+ check_sorted (["a" ,"b" ], ["a" ,"b" ])
160+ check_sorted (["b" ,"a" ], ["a" ,"b" ])
161+ check_sorted (
162+ ["a" ,"b[a]" ,"b[b]" ,"b[c]" ,"c" ], ["a" ,"b[a]" ,"b[b]" ,"b[c]" ,"c" ]
163+ )
164+ check_sorted (
165+ ["a" ,"b[c]" ,"b[a]" ,"b[b]" ,"c" ], ["a" ,"b[c]" ,"b[a]" ,"b[b]" ,"c" ]
166+ )
167+ check_sorted (
168+ ["d" ,"b[c]" ,"b[a]" ,"b[b]" ,"c" ], ["b[c]" ,"b[a]" ,"b[b]" ,"c" ,"d" ]
169+ )
170+ check_sorted (
171+ ["a1" ,"b[c]" ,"b[a]" ,"b[b]" ,"a2" ], ["a1" ,"a2" ,"b[c]" ,"b[a]" ,"b[b]" ]
172+ )