@@ -240,7 +240,8 @@ def test_create_v1_batch_logged_user(self, mocker):
240240 response = self .client .get (response .url )
241241 self .assertEqual (response .status_code , 200 )
242242
243- response = self .client .post ("/batch/new/preview/allow_start/" )
243+ pk = Batch .objects .last ().pk
244+ response = self .client .post (f"/batch/new/preview/{ pk } /allow_start/" )
244245 self .assertEqual (response .status_code , 302 )
245246
246247 response = self .client .get (response .url )
@@ -270,7 +271,8 @@ def test_create_empty_name(self, mocker):
270271 self .assertEqual (response .status_code , 302 )
271272 response = self .client .get (response .url )
272273 self .assertEqual (response .status_code , 200 )
273- response = self .client .post ("/batch/new/preview/allow_start/" )
274+ pk = Batch .objects .last ().pk
275+ response = self .client .post (f"/batch/new/preview/{ pk } /allow_start/" )
274276 self .assertEqual (response .status_code , 302 )
275277 response = self .client .get (response .url )
276278 self .assertTemplateUsed ("batch.html" )
@@ -364,7 +366,8 @@ def test_create_csv_batch_logged_user(self, mocker):
364366 response = self .client .get (response .url )
365367 self .assertEqual (response .status_code , 200 )
366368
367- response = self .client .post ("/batch/new/preview/allow_start/" )
369+ pk = Batch .objects .last ().pk
370+ response = self .client .post (f"/batch/new/preview/{ pk } /allow_start/" )
368371 self .assertEqual (response .status_code , 302 )
369372
370373 response = self .client .get (response .url )
@@ -434,7 +437,8 @@ def test_create_csv_batch_with_file(self, mocker):
434437 response = self .client .get (response .url )
435438 self .assertEqual (response .status_code , 200 )
436439
437- response = self .client .post ("/batch/new/preview/allow_start/" )
440+ pk = Batch .objects .last ().pk
441+ response = self .client .post (f"/batch/new/preview/{ pk } /allow_start/" )
438442 self .assertEqual (response .status_code , 302 )
439443
440444 response = self .client .get (response .url )
@@ -484,7 +488,8 @@ def test_create_v1_batch_with_file(self, mocker):
484488 response = self .client .get (response .url )
485489 self .assertEqual (response .status_code , 200 )
486490
487- response = self .client .post ("/batch/new/preview/allow_start/" )
491+ pk = Batch .objects .last ().pk
492+ response = self .client .post (f"/batch/new/preview/{ pk } /allow_start/" )
488493 self .assertEqual (response .status_code , 302 )
489494
490495 response = self .client .get (response .url )
@@ -608,15 +613,20 @@ def test_allow_start_after_create(self, mocker):
608613 },
609614 )
610615 self .assertEqual (response .status_code , 302 )
611- self .assertEqual (response .url , "/batch/new/preview/" )
616+ pk = Batch .objects .last ().pk
617+ self .assertEqual (response .url , f"/batch/new/preview/{ pk } /" )
618+
619+ response = self .client .get ("/batch/new/preview/" )
620+ self .assertEqual (response .status_code , 302 )
621+ self .assertEqual (response .url , f"/batch/new/preview/{ pk } /" )
612622
613623 response = self .client .get (response .url )
614624 self .assertEqual (response .status_code , 200 )
615625 self .assertTemplateUsed ("preview_batch.html" )
616626
617- response = self .client .get ("/batch/new/preview/allow_start/" )
627+ response = self .client .get (f "/batch/new/preview/ { pk } /allow_start/" )
618628 self .assertEqual (response .status_code , 405 )
619- response = self .client .post ("/batch/new/preview/allow_start/" )
629+ response = self .client .post (f "/batch/new/preview/ { pk } /allow_start/" )
620630 self .assertEqual (response .status_code , 302 )
621631
622632 response = self .client .get (response .url )
@@ -724,7 +734,8 @@ def test_batch_does_not_call_autoconfirmed_if_not_in_preview(self, mocker):
724734 url = res .url
725735 res = self .client .get (url )
726736 self .assertEqual (res .context ["is_autoconfirmed" ], True )
727- response = self .client .post ("/batch/new/preview/allow_start/" )
737+ pk = Batch .objects .last ().pk
738+ response = self .client .post (f"/batch/new/preview/{ pk } /allow_start/" )
728739 batch_url = response .url
729740 response = self .client .get (batch_url )
730741 batch = response .context ["batch" ]
@@ -810,7 +821,8 @@ def test_restart_after_stopped_buttons(self, mocker):
810821 response = self .client .get (response .url )
811822 self .assertInRes ("Save and run batch" , response )
812823
813- response = self .client .post ("/batch/new/preview/allow_start/" )
824+ pk = Batch .objects .last ().pk
825+ response = self .client .post (f"/batch/new/preview/{ pk } /allow_start/" )
814826 response = self .client .get (response .url )
815827 self .assertInRes ("Stop execution" , response )
816828
@@ -927,7 +939,8 @@ def test_batch_preview_commands(self, mocker):
927939 res = self .client .get (res .url )
928940 self .assertEqual (res .status_code , 200 )
929941 self .assertInRes ("Save and run batch" , res )
930- res = self .client .get ("/batch/new/preview/commands/" )
942+ pk = Batch .objects .last ().pk
943+ res = self .client .get (f"/batch/new/preview/{ pk } /commands/" )
931944 self .assertEqual (res .status_code , 200 )
932945
933946 @requests_mock .Mocker ()
@@ -1009,11 +1022,12 @@ def test_batch_summary(self, mocker):
10091022 """ ,
10101023 },
10111024 )
1012- response = self .client .get ("/batch/new/preview/" )
1025+ pk = Batch .objects .last ().pk
1026+ response = self .client .get (f"/batch/new/preview/{ pk } /" )
10131027 self .assertEqual (response .status_code , 200 )
10141028 self .assertTemplateUsed ("preview_batch.html" )
10151029 self .assertInRes ("linear-gradient(to right, green 0%, #C52F21 0)" , response )
1016- response = self .client .post ("/batch/new/preview/allow_start/" )
1030+ response = self .client .post (f "/batch/new/preview/ { pk } /allow_start/" )
10171031 self .assertEqual (response .status_code , 302 )
10181032 response = self .client .get (response .url )
10191033 self .assertEqual (response .status_code , 200 )
@@ -1175,7 +1189,8 @@ def test_batch_stop_permissions(self, mocker):
11751189 response = self .client .get (response .url )
11761190 self .assertInRes ("Save and run batch" , response )
11771191
1178- response = self .client .post ("/batch/new/preview/allow_start/" )
1192+ pk = Batch .objects .last ().pk
1193+ response = self .client .post (f"/batch/new/preview/{ pk } /allow_start/" )
11791194 response = self .client .get (response .url )
11801195 self .assertInRes ("Stop execution" , response )
11811196
@@ -1249,7 +1264,8 @@ def test_batch_restart_permissions(self, mocker):
12491264 response = self .client .get (response .url )
12501265 self .assertInRes ("Save and run batch" , response )
12511266
1252- response = self .client .post ("/batch/new/preview/allow_start/" )
1267+ pk = Batch .objects .last ().pk
1268+ response = self .client .post (f"/batch/new/preview/{ pk } /allow_start/" )
12531269 response = self .client .get (response .url )
12541270 self .assertInRes ("Stop execution" , response )
12551271
@@ -1334,7 +1350,8 @@ def test_batch_rerun_permissions(self, mocker):
13341350 )
13351351 self .assertEqual (response .status_code , 302 )
13361352
1337- response = self .client .post ("/batch/new/preview/allow_start/" )
1353+ pk = Batch .objects .last ().pk
1354+ response = self .client .post (f"/batch/new/preview/{ pk } /allow_start/" )
13381355 response = self .client .get (response .url )
13391356 self .assertInRes ("Stop execution" , response )
13401357
@@ -1421,7 +1438,8 @@ def test_batch_report_permissions(self, mocker):
14211438 )
14221439 self .assertEqual (response .status_code , 302 )
14231440
1424- response = self .client .post ("/batch/new/preview/allow_start/" )
1441+ pk = Batch .objects .last ().pk
1442+ response = self .client .post (f"/batch/new/preview/{ pk } /allow_start/" )
14251443 response = self .client .get (response .url )
14261444 self .assertInRes ("Stop execution" , response )
14271445
0 commit comments