@@ -16,7 +16,7 @@ def are_url_queries_equal(url1, url2, *more_urls):
16
16
query = urllib .parse .parse_qs (query_string )
17
17
queries .append (query )
18
18
for i in range (1 , len (queries )):
19
- if not (queries [i - 1 ] == queries [i ]):
19
+ if not (queries [i - 1 ] == queries [i ]):
20
20
return False
21
21
return True
22
22
@@ -27,9 +27,13 @@ def test_are_url_queries_equal(self):
27
27
assert are_url_queries_equal ('https://google.com' , 'https://google.com' )
28
28
assert not are_url_queries_equal ('https://google.com?q=1' , 'https://google.com?q=2' )
29
29
assert not are_url_queries_equal ('https://google.com?q=1' , 'https://google.com?q=2' , 'https://google.com?q=3' )
30
- assert not are_url_queries_equal ('https://google.com?q=1' , 'https://google.com?q=2' , 'https://google.com?q=3' , 'https://google.com?q=4' )
30
+ assert not are_url_queries_equal (
31
+ 'https://google.com?q=1' , 'https://google.com?q=2' , 'https://google.com?q=3' , 'https://google.com?q=4'
32
+ )
31
33
assert are_url_queries_equal ('https://google.com?q=1' , 'https://google.com?q=1' , 'https://google.com?q=1' )
32
- assert are_url_queries_equal ('https://google.com?q=1' , 'https://google.com?q=1' , 'https://google.com?q=1' , 'https://google.com?q=1' )
34
+ assert are_url_queries_equal (
35
+ 'https://google.com?q=1' , 'https://google.com?q=1' , 'https://google.com?q=1' , 'https://google.com?q=1'
36
+ )
33
37
assert are_url_queries_equal ('https://google.com?q=1&r=2' , 'https://google.com?r=2&q=1' )
34
38
with pytest .raises (TypeError ):
35
39
are_url_queries_equal ('https://google.com?q=1' )
@@ -46,94 +50,77 @@ def test_api_raises_on_unknown_param(self):
46
50
47
51
@responses .activate
48
52
def test_all (self ):
49
- responses .add (responses .GET , 'https://gitcoin.co/api/v0.1/bounties/' ,
50
- json = {'mock' : 'mock' }, status = 200 )
53
+ responses .add (responses .GET , 'https://gitcoin.co/api/v0.1/bounties/' , json = {'mock' : 'mock' }, status = 200 )
51
54
api = Gitcoin ()
52
55
result = api .bounties .all ()
53
56
assert result == {'mock' : 'mock' }
54
57
assert len (responses .calls ) == 1
55
- assert are_url_queries_equal (
56
- responses .calls [0 ].request .url ,
57
- 'https://gitcoin.co/api/v0.1/bounties/'
58
- )
58
+ assert are_url_queries_equal (responses .calls [0 ].request .url , 'https://gitcoin.co/api/v0.1/bounties/' )
59
59
60
60
@responses .activate
61
61
def test_filter_pk__gt (self ):
62
- responses .add (responses .GET , 'https://gitcoin.co/api/v0.1/bounties/' ,
63
- json = {'mock' : 'mock' }, status = 200 )
62
+ responses .add (responses .GET , 'https://gitcoin.co/api/v0.1/bounties/' , json = {'mock' : 'mock' }, status = 200 )
64
63
api = Gitcoin ()
65
64
result = api .bounties .filter (pk__gt = 100 ).all ()
66
65
assert result == {'mock' : 'mock' }
67
66
assert len (responses .calls ) == 1
68
- assert are_url_queries_equal (
69
- responses .calls [0 ].request .url ,
70
- 'https://gitcoin.co/api/v0.1/bounties/?pk__gt=100'
71
- )
67
+ assert are_url_queries_equal (responses .calls [0 ].request .url , 'https://gitcoin.co/api/v0.1/bounties/?pk__gt=100' )
72
68
73
69
@responses .activate
74
70
def test_filter_experience_level (self ):
75
- responses .add (responses .GET , 'https://gitcoin.co/api/v0.1/bounties/' ,
76
- json = {'mock' : 'mock' }, status = 200 )
71
+ responses .add (responses .GET , 'https://gitcoin.co/api/v0.1/bounties/' , json = {'mock' : 'mock' }, status = 200 )
77
72
api = Gitcoin ()
78
73
result = api .bounties .filter (experience_level = 'Beginner' ).all ()
79
74
assert result == {'mock' : 'mock' }
80
75
assert len (responses .calls ) == 1
81
76
assert are_url_queries_equal (
82
- responses .calls [0 ].request .url ,
83
- 'https://gitcoin.co/api/v0.1/bounties/?experience_level=Beginner'
77
+ responses .calls [0 ].request .url , 'https://gitcoin.co/api/v0.1/bounties/?experience_level=Beginner'
84
78
)
85
79
with pytest .raises (ValueError ):
86
80
api .bounties .filter (experience_level = 'Rockstar' )
87
81
88
82
@responses .activate
89
83
def test_filter_project_length (self ):
90
- responses .add (responses .GET , 'https://gitcoin.co/api/v0.1/bounties/' ,
91
- json = {'mock' : 'mock' }, status = 200 )
84
+ responses .add (responses .GET , 'https://gitcoin.co/api/v0.1/bounties/' , json = {'mock' : 'mock' }, status = 200 )
92
85
api = Gitcoin ()
93
86
result = api .bounties .filter (project_length = 'Hours' ).all ()
94
87
assert result == {'mock' : 'mock' }
95
88
assert len (responses .calls ) == 1
96
89
assert are_url_queries_equal (
97
- responses .calls [0 ].request .url ,
98
- 'https://gitcoin.co/api/v0.1/bounties/?project_length=Hours'
90
+ responses .calls [0 ].request .url , 'https://gitcoin.co/api/v0.1/bounties/?project_length=Hours'
99
91
)
100
92
with pytest .raises (ValueError ):
101
93
api .bounties .filter (project_length = 'Minutes' )
102
94
103
95
@responses .activate
104
96
def test_filter_bounty_type (self ):
105
- responses .add (responses .GET , 'https://gitcoin.co/api/v0.1/bounties/' ,
106
- json = {'mock' : 'mock' }, status = 200 )
97
+ responses .add (responses .GET , 'https://gitcoin.co/api/v0.1/bounties/' , json = {'mock' : 'mock' }, status = 200 )
107
98
api = Gitcoin ()
108
99
result = api .bounties .filter (bounty_type = 'Bug' ).all ()
109
100
assert result == {'mock' : 'mock' }
110
101
assert len (responses .calls ) == 1
111
102
assert are_url_queries_equal (
112
- responses .calls [0 ].request .url ,
113
- 'https://gitcoin.co/api/v0.1/bounties/?bounty_type=Bug'
103
+ responses .calls [0 ].request .url , 'https://gitcoin.co/api/v0.1/bounties/?bounty_type=Bug'
114
104
)
115
105
with pytest .raises (ValueError ):
116
106
api .bounties .filter (bounty_type = 'Fancy' )
117
107
118
108
@responses .activate
119
109
def test_filter_idx_status (self ):
120
- responses .add (responses .GET , 'https://gitcoin.co/api/v0.1/bounties/' ,
121
- json = {'mock' : 'mock' }, status = 200 )
110
+ responses .add (responses .GET , 'https://gitcoin.co/api/v0.1/bounties/' , json = {'mock' : 'mock' }, status = 200 )
122
111
api = Gitcoin ()
123
112
result = api .bounties .filter (idx_status = 'started' ).all ()
124
113
assert result == {'mock' : 'mock' }
125
114
assert len (responses .calls ) == 1
126
115
assert are_url_queries_equal (
127
- responses .calls [0 ].request .url ,
128
- 'https://gitcoin.co/api/v0.1/bounties/?idx_status=started'
116
+ responses .calls [0 ].request .url , 'https://gitcoin.co/api/v0.1/bounties/?idx_status=started'
129
117
)
130
118
with pytest .raises (ValueError ):
131
119
api .bounties .filter (idx_status = 'undone' )
132
120
133
121
@responses .activate
134
122
def test_filter_2x_bounty_type_paged (self ):
135
- responses .add (responses .GET , 'https://gitcoin.co/api/v0.1/bounties/' ,
136
- json = {'mock' : 'mock' }, status = 200 )
123
+ responses .add (responses .GET , 'https://gitcoin.co/api/v0.1/bounties/' , json = {'mock' : 'mock' }, status = 200 )
137
124
api = Gitcoin ()
138
125
result = api .bounties .filter (bounty_type = 'Feature' ).filter (bounty_type = 'Bug' ).get_page ()
139
126
assert result == {'mock' : 'mock' }
@@ -145,10 +132,10 @@ def test_filter_2x_bounty_type_paged(self):
145
132
146
133
@responses .activate
147
134
def test_del_param (self ):
148
- responses .add (responses .GET , 'https://gitcoin.co/api/v0.1/bounties/' ,
149
- json = {'mock' : 'mock' }, status = 200 )
135
+ responses .add (responses .GET , 'https://gitcoin.co/api/v0.1/bounties/' , json = {'mock' : 'mock' }, status = 200 )
150
136
api = Gitcoin ()
151
- result = api .bounties .filter (bounty_type = 'Feature' )._del_param ('bounty_type' ).filter (bounty_type = 'Bug' ).get_page ()
137
+ result = api .bounties .filter (bounty_type = 'Feature' ) \
138
+ ._del_param ('bounty_type' ).filter (bounty_type = 'Bug' ).get_page ()
152
139
assert result == {'mock' : 'mock' }
153
140
assert len (responses .calls ) == 1
154
141
assert are_url_queries_equal (
@@ -158,8 +145,7 @@ def test_del_param(self):
158
145
159
146
@responses .activate
160
147
def test_reset_all_params (self ):
161
- responses .add (responses .GET , 'https://gitcoin.co/api/v0.1/bounties/' ,
162
- json = {'mock' : 'mock' }, status = 200 )
148
+ responses .add (responses .GET , 'https://gitcoin.co/api/v0.1/bounties/' , json = {'mock' : 'mock' }, status = 200 )
163
149
api = Gitcoin ()
164
150
bounties_api = api .bounties
165
151
@@ -177,14 +163,12 @@ def test_reset_all_params(self):
177
163
assert result == {'mock' : 'mock' }
178
164
assert len (responses .calls ) == 2
179
165
assert are_url_queries_equal (
180
- responses .calls [1 ].request .url ,
181
- 'https://gitcoin.co/api/v0.1/bounties/?bounty_type=Bug&offset=0&limit=25'
166
+ responses .calls [1 ].request .url , 'https://gitcoin.co/api/v0.1/bounties/?bounty_type=Bug&offset=0&limit=25'
182
167
)
183
168
184
169
@responses .activate
185
170
def test_order_by (self ):
186
- responses .add (responses .GET , 'https://gitcoin.co/api/v0.1/bounties/' ,
187
- json = {'mock' : 'mock' }, status = 200 )
171
+ responses .add (responses .GET , 'https://gitcoin.co/api/v0.1/bounties/' , json = {'mock' : 'mock' }, status = 200 )
188
172
api = Gitcoin ()
189
173
190
174
result = api .bounties .order_by ('-project_length' ).get_page ()
@@ -208,8 +192,7 @@ def test_order_by(self):
208
192
209
193
@responses .activate
210
194
def test_get (self ):
211
- responses .add (responses .GET , 'https://gitcoin.co/api/v0.1/bounties/123' ,
212
- json = {'mock' : 'mock' }, status = 200 )
195
+ responses .add (responses .GET , 'https://gitcoin.co/api/v0.1/bounties/123' , json = {'mock' : 'mock' }, status = 200 )
213
196
api = Gitcoin ()
214
197
result = api .bounties .get (123 )
215
198
assert result == {'mock' : 'mock' }
@@ -218,16 +201,17 @@ def test_get(self):
218
201
219
202
@responses .activate
220
203
def test_no_normalize (self ):
204
+
221
205
class ExtendedBountyConfig (BountyConfig ):
206
+
222
207
def __init__ (self ):
223
208
super ().__init__ ()
224
209
self .params ['no_normalize' ] = (True , None )
225
210
226
211
api = Gitcoin ()
227
212
api .set_class ('bounties_list_config' , ExtendedBountyConfig )
228
213
229
- responses .add (responses .GET , 'https://gitcoin.co/api/v0.1/bounties/' ,
230
- json = {'mock' : 'mock' }, status = 200 )
214
+ responses .add (responses .GET , 'https://gitcoin.co/api/v0.1/bounties/' , json = {'mock' : 'mock' }, status = 200 )
231
215
232
216
result = api .bounties .filter (no_normalize = 'not_normal' ).get_page ()
233
217
assert result == {'mock' : 'mock' }
@@ -239,14 +223,15 @@ def __init__(self):
239
223
240
224
@responses .activate
241
225
def test_raise_for_status (self ):
242
- responses .add (responses .GET , 'https://gitcoin.co/api/v0.1/bounties/' ,
243
- json = {'mock' : 'mock' }, status = 401 )
226
+ responses .add (responses .GET , 'https://gitcoin.co/api/v0.1/bounties/' , json = {'mock' : 'mock' }, status = 401 )
244
227
api = Gitcoin ()
245
228
with pytest .raises (requests .exceptions .HTTPError ):
246
229
result = api .bounties .all ()
247
230
248
231
def test_extending_config_does_not_leak (self ):
232
+
249
233
class ExtendedBountyConfig (BountyConfig ):
234
+
250
235
def __init__ (self ):
251
236
super ().__init__ ()
252
237
self .params ['extra_config' ] = (True , None )
0 commit comments