@@ -33,6 +33,9 @@ def login(self):
33
33
def is_admin (self ):
34
34
raise NotImplementedError
35
35
36
+ def get_url_path_ctx (self ):
37
+ return {}
38
+
36
39
def assertResponse (self , path , name = None , method = None , data = None , ** kwargs ):
37
40
self .login ()
38
41
if method is None :
@@ -57,7 +60,7 @@ def assertResponse(self, path, name=None, method=None, data=None, **kwargs):
57
60
response_data = self .response_data .get (name , {}).copy ()
58
61
59
62
response_attrs = {
60
- 'status_code' : kwargs .pop ('status_code' , self .default_status_code ),
63
+ 'status_code' : response_data .pop ('status_code' , self .default_status_code ),
61
64
}
62
65
response_attrs .update (kwargs )
63
66
response_attrs .update (response_data )
@@ -98,6 +101,13 @@ def setUp(self):
98
101
def _test_url (self , urlpatterns ):
99
102
deconstructed_urls = extract_views_from_urlpatterns (urlpatterns )
100
103
added_kwargs = {}
104
+
105
+ # we need to format urls with proper ids
106
+ url_ctx = self .get_url_path_ctx ()
107
+ if url_ctx :
108
+ self .response_data = {
109
+ url .format (** url_ctx ): data for url , data in self .response_data .items ()}
110
+
101
111
for (view , regex , namespace , name ) in deconstructed_urls :
102
112
request_data = self .request_data .get (name , {}).copy ()
103
113
for key in list (re .compile (regex ).groupindex .keys ()):
@@ -231,10 +241,15 @@ class PrivateProjectAdminAccessTest(PrivateProjectMixin, TestCase):
231
241
'/dashboard/pip/redirects/delete/' : {'status_code' : 405 },
232
242
'/dashboard/pip/subprojects/sub/delete/' : {'status_code' : 405 },
233
243
'/dashboard/pip/integrations/sync/' : {'status_code' : 405 },
234
- '/dashboard/pip/integrations/1 /sync/' : {'status_code' : 405 },
235
- '/dashboard/pip/integrations/1 /delete/' : {'status_code' : 405 },
244
+ '/dashboard/pip/integrations/{integration_id} /sync/' : {'status_code' : 405 },
245
+ '/dashboard/pip/integrations/{integration_id} /delete/' : {'status_code' : 405 },
236
246
}
237
247
248
+ def get_url_path_ctx (self ):
249
+ return {
250
+ 'integration_id' : self .integration .id ,
251
+ }
252
+
238
253
def login (self ):
239
254
return self .client .login (username = 'owner' , password = 'test' )
240
255
@@ -260,13 +275,18 @@ class PrivateProjectUserAccessTest(PrivateProjectMixin, TestCase):
260
275
'/dashboard/pip/redirects/delete/' : {'status_code' : 405 },
261
276
'/dashboard/pip/subprojects/sub/delete/' : {'status_code' : 405 },
262
277
'/dashboard/pip/integrations/sync/' : {'status_code' : 405 },
263
- '/dashboard/pip/integrations/1 /sync/' : {'status_code' : 405 },
264
- '/dashboard/pip/integrations/1 /delete/' : {'status_code' : 405 },
278
+ '/dashboard/pip/integrations/{integration_id} /sync/' : {'status_code' : 405 },
279
+ '/dashboard/pip/integrations/{integration_id} /delete/' : {'status_code' : 405 },
265
280
}
266
281
267
282
# Filtered out by queryset on projects that we don't own.
268
283
default_status_code = 404
269
284
285
+ def get_url_path_ctx (self ):
286
+ return {
287
+ 'integration_id' : self .integration .id ,
288
+ }
289
+
270
290
def login (self ):
271
291
return self .client .login (username = 'tester' , password = 'test' )
272
292
0 commit comments