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