@@ -12,8 +12,12 @@ class ActionTestCase(TestFixture, CMSTestCase):
1212 def setUp (self ):
1313 super ().setUp ()
1414 self .actions = get_registered_actions ()
15- self .save_action = [key for key , value in self .actions if value == "Save form submission" ][0 ]
16- self .send_mail_action = [key for key , value in self .actions if value == "Send email" ][0 ]
15+ self .save_action = [
16+ key for key , value in self .actions if value == "Save form submission"
17+ ][0 ]
18+ self .send_mail_action = [
19+ key for key , value in self .actions if value == "Send email"
20+ ][0 ]
1721
1822 def test_send_mail_action (self ):
1923 plugin_instance = add_plugin (
@@ -22,16 +26,19 @@ def test_send_mail_action(self):
2226 language = self .language ,
2327 form_name = "test_form" ,
2428 )
25- plugin_instance .
action_parameters = {
"sendemail_recipients" :
"[email protected] [email protected] " ,
"sendemail_template" :
"default" }
26- plugin_instance .form_actions = f"[\" { self .send_mail_action } \" ]"
29+ plugin_instance .action_parameters = {
30+ 31+ "sendemail_template" : "default" ,
32+ }
33+ plugin_instance .form_actions = f'["{ self .send_mail_action } "]'
2734 plugin_instance .save ()
2835
2936 child_plugin = add_plugin (
3037 placeholder = self .placeholder ,
3138 plugin_type = "CharFieldPlugin" ,
3239 language = self .language ,
3340 target = plugin_instance ,
34- config = {"field_name" : "field1" }
41+ config = {"field_name" : "field1" },
3542 )
3643 child_plugin .save ()
3744 plugin_instance .child_plugin_instances = [child_plugin ]
@@ -49,12 +56,15 @@ def test_send_mail_action(self):
4956 # Validate send_mail call
5057 mock_send_mail .assert_called_once ()
5158 args , kwargs = mock_send_mail .call_args
52- self .assertEqual (args [0 ], ' Test form form submission' )
53- self .assertIn (' Form submission' , args [1 ])
54- self .
assertEqual (
args [
3 ], [
' [email protected] ' , ' [email protected] ' ])
59+ self .assertEqual (args [0 ], " Test form form submission" )
60+ self .assertIn (" Form submission" , args [1 ])
61+ self .
assertEqual (
args [
3 ], [
" [email protected] " , " [email protected] " ])
5562
5663 # Test with no recipients
57- plugin_instance .action_parameters = {"sendemail_recipients" : "" , "sendemail_template" : "default" }
64+ plugin_instance .action_parameters = {
65+ "sendemail_recipients" : "" ,
66+ "sendemail_template" : "default" ,
67+ }
5868 plugin_instance .save ()
5969
6070 with patch ("django.core.mail.mail_admins" ) as mock_mail_admins :
@@ -65,5 +75,5 @@ def test_send_mail_action(self):
6575 # Validate mail_admins call
6676 mock_mail_admins .assert_called_once ()
6777 args , kwargs = mock_mail_admins .call_args
68- self .assertEqual (args [0 ], ' Test form form submission' )
69- self .assertIn (' Form submission' , args [1 ])
78+ self .assertEqual (args [0 ], " Test form form submission" )
79+ self .assertIn (" Form submission" , args [1 ])
0 commit comments