@@ -36,6 +36,19 @@ def test_petition_detail(self):
36
36
self .assertContains (response , text = '<meta property="og:url" content="http://testserver/petition/{}/" />'
37
37
.format (petition .id ))
38
38
39
+ def test_fill_petition_when_logged (self ):
40
+ """ if logged in, the petition form should be pre filled with user account info """
41
+ petition = Petition .objects .filter (user__user__username = "julia" ).first ()
42
+ self .login ('john' )
43
+ response = self .client .get (reverse ("detail" , args = [petition .id ]))
44
+ self .assertEqual (response .status_code , 200 )
45
+ self .assertEqual (response .context ['petition' ], petition )
46
+ self .assertTemplateUsed (response , "petition/petition_detail.html" )
47
+
48
+ form = response .context ['form' ]
49
+ self .assertEqual (form .is_bound , True )
50
+ self .assertContains (response , text = 'value="John"' )
51
+
39
52
def test_petition_success_msg (self ):
40
53
""" Test that the success modal is there when signing and confirming """
41
54
petition = Petition .objects .filter (published = True ).first ()
@@ -228,4 +241,4 @@ def test_petition_unpublish_org(self):
228
241
response = self .client .get (reverse ("petition_unpublish" , args = [petition .id ]))
229
242
petition .refresh_from_db ()
230
243
self .assertEqual (response .status_code , 403 )
231
- self .assertEqual (petition .published , True )
244
+ self .assertEqual (petition .published , True )
0 commit comments