@@ -45,7 +45,10 @@ def setUp(self) -> None:
45
45
self .login_url = reverse ("login" )
46
46
self .list_url = reverse ("collaborate:plan_list" )
47
47
self .choose_template_url = reverse ("collaborate:plan_choose_template" )
48
- self .create_url = reverse ("collaborate:plan_create" )
48
+ # TODO: new tests for choosing template form
49
+ self .create_url = reverse ("collaborate:plan_create_no_template" )
50
+ self .create_with_template_url = reverse ("collaborate:plan_create_with_template" )
51
+ # TODO: new tests for creating plan from template where Title/Goal are prefilled, but Contact/Enddate are not.
49
52
self .detail_url = reverse (
50
53
"collaborate:plan_detail" , kwargs = {"uuid" : self .plan .uuid }
51
54
)
@@ -316,11 +319,11 @@ def test_plan_action_create_not_your_action(self):
316
319
other_user = UserFactory ()
317
320
self .app .get (self .action_add_url , user = other_user , status = 404 )
318
321
319
- def test_plan_create_login_required (self ):
322
+ def test_plan_create_no_template_login_required (self ):
320
323
response = self .app .get (self .create_url )
321
324
self .assertRedirects (response , f"{ self .login_url } ?next={ self .create_url } " )
322
325
323
- def test_plan_create_fields_required (self ):
326
+ def test_plan_create_no_template_fields_required (self ):
324
327
response = self .app .get (self .create_url , user = self .user )
325
328
form = response .forms ["plan-form" ]
326
329
response = form .submit ()
@@ -334,7 +337,7 @@ def test_plan_create_fields_required(self):
334
337
},
335
338
)
336
339
337
- def test_plan_create_fails_with_no_collaborators (self ):
340
+ def test_plan_create_no_template_fails_with_no_collaborators (self ):
338
341
response = self .app .get (self .create_url , user = self .user )
339
342
form = response .forms ["plan-form" ]
340
343
form ["title" ] = "Plan"
@@ -349,7 +352,7 @@ def test_plan_create_fails_with_no_collaborators(self):
349
352
{"__all__" : [_ ("At least one collaborator is required for a plan." )]},
350
353
)
351
354
352
- def test_plan_create_contains_expected_contacts (self ):
355
+ def test_plan_create_no_template_contains_expected_contacts (self ):
353
356
another_contact = UserFactory ()
354
357
self .user .user_contacts .add (another_contact )
355
358
response = self .app .get (self .create_url , user = self .user )
@@ -362,7 +365,7 @@ def test_plan_create_contains_expected_contacts(self):
362
365
self .assertIn (self .contact .get_full_name (), rendered_contacts )
363
366
self .assertIn (another_contact .get_full_name (), rendered_contacts )
364
367
365
- def test_plan_create_plan (self ):
368
+ def test_plan_create_no_template_plan (self ):
366
369
self .assertEqual (Plan .objects .count (), 1 )
367
370
response = self .app .get (self .create_url , user = self .user )
368
371
form = response .forms ["plan-form" ]
@@ -379,10 +382,10 @@ def test_plan_create_plan(self):
379
382
self .assertEqual (plan .goal , "Goal" )
380
383
self .assertEqual (plan .description , "Description" )
381
384
382
- def test_plan_create_plan_with_template (self ):
385
+ def test_plan_create_no_template_plan_with_template (self ):
383
386
plan_template = PlanTemplateFactory (file = None )
384
387
self .assertEqual (Plan .objects .count (), 1 )
385
- response = self .app .get (self .choose_template_url , user = self .user )
388
+ response = self .app .get (self .create_url , user = self .user )
386
389
form = response .forms ["plan-form" ]
387
390
form ["title" ] = "Plan"
388
391
form ["end_date" ] = "2022-01-01"
@@ -398,7 +401,7 @@ def test_plan_create_plan_with_template(self):
398
401
self .assertEqual (plan .documents .count (), 0 )
399
402
self .assertEqual (plan .actions .count (), 0 )
400
403
401
- def test_plan_create_plan_with_template_and_field_overrides (self ):
404
+ def test_plan_create_no_template_plan_with_template_and_field_overrides (self ):
402
405
plan_template = PlanTemplateFactory (file = None )
403
406
self .assertEqual (Plan .objects .count (), 1 )
404
407
response = self .app .get (self .create_url , user = self .user )
@@ -419,7 +422,7 @@ def test_plan_create_plan_with_template_and_field_overrides(self):
419
422
self .assertEqual (plan .documents .count (), 0 )
420
423
self .assertEqual (plan .actions .count (), 0 )
421
424
422
- def test_plan_create_plan_with_template_and_file (self ):
425
+ def test_plan_create_no_template_plan_with_template_and_file (self ):
423
426
plan_template = PlanTemplateFactory ()
424
427
self .assertEqual (Plan .objects .count (), 1 )
425
428
response = self .app .get (self .create_url , user = self .user )
@@ -438,7 +441,7 @@ def test_plan_create_plan_with_template_and_file(self):
438
441
self .assertEqual (plan .documents .count (), 1 )
439
442
self .assertEqual (plan .actions .count (), 0 )
440
443
441
- def test_plan_create_plan_with_template_and_actions (self ):
444
+ def test_plan_create_no_template_plan_with_template_and_actions (self ):
442
445
plan_template = PlanTemplateFactory (file = None )
443
446
ActionTemplateFactory (plan_template = plan_template )
444
447
self .assertEqual (Plan .objects .count (), 1 )
@@ -458,7 +461,9 @@ def test_plan_create_plan_with_template_and_actions(self):
458
461
self .assertEqual (plan .documents .count (), 0 )
459
462
self .assertEqual (plan .actions .count (), 1 )
460
463
461
- def test_plan_create_plan_validation_error_reselects_template_and_contact (self ):
464
+ def test_plan_create_no_template_plan_validation_error_reselects_template_and_contact (
465
+ self ,
466
+ ):
462
467
plan_template = PlanTemplateFactory (file = None )
463
468
ActionTemplateFactory (plan_template = plan_template )
464
469
# make sure we have only one plan
@@ -484,12 +489,14 @@ def test_plan_create_plan_validation_error_reselects_template_and_contact(self):
484
489
elem = response .pyquery ("#id_plan_contacts_1" )[0 ]
485
490
self .assertEqual (elem .attrib .get ("checked" ), "checked" )
486
491
487
- def test_plan_create_contains_contact_create_link_when_no_contacts_exist (self ):
492
+ def test_plan_create_no_template_contains_contact_create_link_when_no_contacts_exist (
493
+ self ,
494
+ ):
488
495
self .user .user_contacts .remove (self .contact )
489
496
response = self .app .get (self .create_url , user = self .user )
490
497
self .assertContains (response , reverse ("profile:contact_create" ))
491
498
492
- def test_plan_create_does_not_contain_contact_create_link_when_contacts_exist (
499
+ def test_plan_create_no_template_does_not_contain_contact_create_link_when_contacts_exist (
493
500
self ,
494
501
):
495
502
response = self .app .get (self .create_url , user = self .user )
0 commit comments