@@ -44,7 +44,11 @@ def setUp(self) -> None:
44
44
45
45
self .login_url = reverse ("login" )
46
46
self .list_url = reverse ("collaborate:plan_list" )
47
- self .create_url = reverse ("collaborate:plan_create" )
47
+ self .choose_template_url = reverse ("collaborate:plan_choose_template" )
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.
48
52
self .detail_url = reverse (
49
53
"collaborate:plan_detail" , kwargs = {"uuid" : self .plan .uuid }
50
54
)
@@ -315,11 +319,11 @@ def test_plan_action_create_not_your_action(self):
315
319
other_user = UserFactory ()
316
320
self .app .get (self .action_add_url , user = other_user , status = 404 )
317
321
318
- def test_plan_create_login_required (self ):
322
+ def test_plan_create_no_template_login_required (self ):
319
323
response = self .app .get (self .create_url )
320
324
self .assertRedirects (response , f"{ self .login_url } ?next={ self .create_url } " )
321
325
322
- def test_plan_create_fields_required (self ):
326
+ def test_plan_create_no_template_fields_required (self ):
323
327
response = self .app .get (self .create_url , user = self .user )
324
328
form = response .forms ["plan-form" ]
325
329
response = form .submit ()
@@ -333,7 +337,7 @@ def test_plan_create_fields_required(self):
333
337
},
334
338
)
335
339
336
- def test_plan_create_fails_with_no_collaborators (self ):
340
+ def test_plan_create_no_template_fails_with_no_collaborators (self ):
337
341
response = self .app .get (self .create_url , user = self .user )
338
342
form = response .forms ["plan-form" ]
339
343
form ["title" ] = "Plan"
@@ -348,20 +352,20 @@ def test_plan_create_fails_with_no_collaborators(self):
348
352
{"__all__" : [_ ("At least one collaborator is required for a plan." )]},
349
353
)
350
354
351
- def test_plan_create_contains_expected_contacts (self ):
355
+ def test_plan_create_no_template_contains_expected_contacts (self ):
352
356
another_contact = UserFactory ()
353
357
self .user .user_contacts .add (another_contact )
354
358
response = self .app .get (self .create_url , user = self .user )
355
359
356
- rendered_contacts = response .pyquery ("#plan-form .grid .form__grid-box " )[
360
+ rendered_contacts = response .pyquery ("#plan-form .plan__contacts " )[
357
361
0
358
362
].text_content ()
359
363
360
364
self .assertNotIn (self .user .get_full_name (), rendered_contacts )
361
365
self .assertIn (self .contact .get_full_name (), rendered_contacts )
362
366
self .assertIn (another_contact .get_full_name (), rendered_contacts )
363
367
364
- def test_plan_create_plan (self ):
368
+ def test_plan_create_no_template_plan (self ):
365
369
self .assertEqual (Plan .objects .count (), 1 )
366
370
response = self .app .get (self .create_url , user = self .user )
367
371
form = response .forms ["plan-form" ]
@@ -378,7 +382,7 @@ def test_plan_create_plan(self):
378
382
self .assertEqual (plan .goal , "Goal" )
379
383
self .assertEqual (plan .description , "Description" )
380
384
381
- def test_plan_create_plan_with_template (self ):
385
+ def test_plan_create_no_template_plan_with_template (self ):
382
386
plan_template = PlanTemplateFactory (file = None )
383
387
self .assertEqual (Plan .objects .count (), 1 )
384
388
response = self .app .get (self .create_url , user = self .user )
@@ -397,7 +401,7 @@ def test_plan_create_plan_with_template(self):
397
401
self .assertEqual (plan .documents .count (), 0 )
398
402
self .assertEqual (plan .actions .count (), 0 )
399
403
400
- 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 ):
401
405
plan_template = PlanTemplateFactory (file = None )
402
406
self .assertEqual (Plan .objects .count (), 1 )
403
407
response = self .app .get (self .create_url , user = self .user )
@@ -418,7 +422,7 @@ def test_plan_create_plan_with_template_and_field_overrides(self):
418
422
self .assertEqual (plan .documents .count (), 0 )
419
423
self .assertEqual (plan .actions .count (), 0 )
420
424
421
- def test_plan_create_plan_with_template_and_file (self ):
425
+ def test_plan_create_no_template_plan_with_template_and_file (self ):
422
426
plan_template = PlanTemplateFactory ()
423
427
self .assertEqual (Plan .objects .count (), 1 )
424
428
response = self .app .get (self .create_url , user = self .user )
@@ -437,7 +441,7 @@ def test_plan_create_plan_with_template_and_file(self):
437
441
self .assertEqual (plan .documents .count (), 1 )
438
442
self .assertEqual (plan .actions .count (), 0 )
439
443
440
- def test_plan_create_plan_with_template_and_actions (self ):
444
+ def test_plan_create_no_template_plan_with_template_and_actions (self ):
441
445
plan_template = PlanTemplateFactory (file = None )
442
446
ActionTemplateFactory (plan_template = plan_template )
443
447
self .assertEqual (Plan .objects .count (), 1 )
@@ -457,7 +461,9 @@ def test_plan_create_plan_with_template_and_actions(self):
457
461
self .assertEqual (plan .documents .count (), 0 )
458
462
self .assertEqual (plan .actions .count (), 1 )
459
463
460
- 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
+ ):
461
467
plan_template = PlanTemplateFactory (file = None )
462
468
ActionTemplateFactory (plan_template = plan_template )
463
469
# make sure we have only one plan
@@ -483,12 +489,14 @@ def test_plan_create_plan_validation_error_reselects_template_and_contact(self):
483
489
elem = response .pyquery ("#id_plan_contacts_1" )[0 ]
484
490
self .assertEqual (elem .attrib .get ("checked" ), "checked" )
485
491
486
- 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
+ ):
487
495
self .user .user_contacts .remove (self .contact )
488
496
response = self .app .get (self .create_url , user = self .user )
489
497
self .assertContains (response , reverse ("profile:contact_create" ))
490
498
491
- 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 (
492
500
self ,
493
501
):
494
502
response = self .app .get (self .create_url , user = self .user )
0 commit comments