@@ -16,39 +16,39 @@ def setUp(self):
16
16
E7F5
self .api = woocommerce .API (
17
17
url = "http://woo.test" ,
18
18
consumer_key = self .consumer_key ,
19
- consumer_secret = self .consumer_secret
19
+ consumer_secret = self .consumer_secret ,
20
20
)
21
21
22
22
def test_version (self ):
23
- """ Test default version """
23
+ """Test default version"""
24
24
api = woocommerce .API (
25
25
url = "https://woo.test" ,
26
26
consumer_key = self .consumer_key ,
27
- consumer_secret = self .consumer_secret
27
+ consumer_secret = self .consumer_secret ,
28
28
)
29
29
30
30
self .assertEqual (api .version , "wc/v3" )
31
31
32
32
def test_non_ssl (self ):
33
- """ Test non-ssl """
33
+ """Test non-ssl"""
34
34
api = woocommerce .API (
35
35
url = "http://woo.test" ,
36
36
consumer_key = self .consumer_key ,
37
- consumer_secret = self .consumer_secret
37
+ consumer_secret = self .consumer_secret ,
38
38
)
39
39
self .assertFalse (api .is_ssl )
40
40
41
41
def test_with_ssl (self ):
42
- """ Test ssl """
42
+ """Test ssl"""
43
43
api = woocommerce .API (
44
44
url = "https://woo.test" ,
45
45
consumer_key = self .consumer_key ,
46
- consumer_secret = self .consumer_secret
46
+ consumer_secret = self .consumer_secret ,
47
47
)
48
48
self .assertTrue (api .is_ssl , True )
49
49
50
50
def test_with_timeout (self ):
51
- """ Test timeout """
51
+ """Test timeout"""
52
52
api = woocommerce .API (
53
53
url = "https://woo.test" ,
54
54
consumer_key = self .consumer_key ,
@@ -59,105 +59,114 @@ def test_with_timeout(self):
59
59
60
60
@all_requests
61
61
def 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" }
65
64
66
65
with HTTMock (woo_test_mock ):
67
66
# call requests
68
67
status = api .get ("products" ).status_code
69
68
self .assertEqual (status , 200 )
70
69
71
70
def test_get (self ):
72
- """ Test GET requests """
71
+ """Test GET requests"""
72
+
73
73
@all_requests
74
74
def 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" }
78
77
79
78
with HTTMock (woo_test_mock ):
80
79
# call requests
81
80
status = self .api .get ("products" ).status_code
82
81
self .assertEqual (status , 200 )
83
82
84
83
def test_get_with_parameters (self ):
85
- """ Test GET requests w/ url params """
84
+ """Test GET requests w/ url params"""
85
+
86
86
@all_requests
87
87
def woo_test_mock (* args , ** kwargs ):
88
- return {'status_code' : 200 ,
89
- 'content' : 'OK' }
88
+ return {"status_code" : 200 , "content" : "OK" }
90
89
91
90
with HTTMock (woo_test_mock ):
92
91
# 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
94
95
self .assertEqual (status , 200 )
95
96
96
97
def test_get_with_requests_kwargs (self ):
97
- """ Test GET requests w/ optional requests-module kwargs """
98
+ """Test GET requests w/ optional requests-module kwargs"""
98
99
99
100
@all_requests
100
101
def woo_test_mock (* args , ** kwargs ):
101
- return {'status_code' : 200 ,
102
- 'content' : 'OK' }
102
+ return {"status_code" : 200 , "content" : "OK" }
103
103
104
104
with HTTMock (woo_test_mock ):
105
105
# call requests
106
106
status = self .api .get ("products" , allow_redirects = True ).status_code
107
107
self .assertEqual (status , 200 )
108
108
109
109
def test_post (self ):
110
- """ Test POST requests """
110
+ """Test POST requests"""
111
+
111
112
@all_requests
112
113
def 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" }
116
116
117
117
with HTTMock (woo_test_mock ):
118
118
# call requests
119
119
status = self .api .post ("products" , {}).status_code
120
120
self .assertEqual (status , 201 )
121
121
122
122
def test_put (self ):
123
- """ Test PUT requests """
123
+ """Test PUT requests"""
124
+
124
125
@all_requests
125
126
def 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" }
129
129
130
130
with HTTMock (woo_test_mock ):
131
131
# call requests
132
132
status = self .api .put ("products" , {}).status_code
133
133
self .assertEqual (status , 200 )
134
134
135
135
def test_delete (self ):
136
- """ Test DELETE requests """
136
+ """Test DELETE requests"""
137
+
137
138
@all_requests
138
139
def 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" }
142
142
143
143
with HTTMock (woo_test_mock ):
144
144
# call requests
145
145
status = self .api .delete ("products" ).status_code
146
146
self .assertEqual (status , 200 )
147
147
148
148
def test_oauth_sorted_params (self ):
149
- """ Test order of parameters for OAuth signature """
149
+ """Test order of parameters for OAuth signature"""
150
+
150
151
def check_sorted (keys , expected ):
151
152
params = oauth .OrderedDict ()
152
153
for key in keys :
153
- params [key ] = ''
154
+ params [key ] = ""
154
155
155
156
ordered = list (oauth .OAuth .sorted_params (params ).keys ())
156
157
self .assertEqual (ordered , expected )
157
158
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
+ )
0 commit comments