@@ -36,6 +36,19 @@ def test_petition_detail(self):
3636 self .assertContains (response , text = '<meta property="og:url" content="http://testserver/petition/{}/" />'
3737 .format (petition .id ))
3838
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+
3952 def test_petition_success_msg (self ):
4053 """ Test that the success modal is there when signing and confirming """
4154 petition = Petition .objects .filter (published = True ).first ()
@@ -228,4 +241,4 @@ def test_petition_unpublish_org(self):
228241 response = self .client .get (reverse ("petition_unpublish" , args = [petition .id ]))
229242 petition .refresh_from_db ()
230243 self .assertEqual (response .status_code , 403 )
231- self .assertEqual (petition .published , True )
244+ self .assertEqual (petition .published , True )
0 commit comments