I would gladly answer to your mass mailing !
+ +--
+ Your Dear Customer
+
+ + +------=_Part_4200734_24778174.1344608186754-- +""" + -class TestAutomationMail(AutomationTestCase): +class TestAutomationMail(AutomationTestCase, MockEmail, HttpCase): def test_activity_execution(self): """ We will check the execution of the tasks and that we cannot execute them again @@ -57,3 +102,168 @@ def test_bounce(self): self.env["mail.thread"]._routing_handle_bounce(False, parsed_bounce_values) self.assertEqual("bounce", record_activity.mail_status) self.assertTrue(record_child_activity.scheduled_date) + + def test_reply(self): + """ + Now we will check the execution of scheduled activities""" + with self.mock_mail_gateway(): + activity = self.create_mail_activity() + child_activity = self.create_mail_activity( + parent_id=activity.id, trigger_type="mail_reply" + ) + self.configuration.domain = "[('id', '=', %s)]" % self.partner_01.id + self.configuration.start_automation() + self.env["automation.configuration"].cron_automation() + self.env["automation.record.activity"]._cron_automation_activities() + record_activity = self.env["automation.record.activity"].search( + [("configuration_activity_id", "=", activity.id)] + ) + record_child_activity = self.env["automation.record.activity"].search( + [("configuration_activity_id", "=", child_activity.id)] + ) + self.assertEqual("sent", record_activity.mail_status) + self.assertTrue(record_child_activity) + self.assertFalse(record_child_activity.scheduled_date) + self.gateway_mail_reply_wrecord( + MAIL_TEMPLATE, self.partner_01, use_in_reply_to=True + ) + self.assertEqual("reply", record_activity.mail_status) + self.assertTrue(record_child_activity.scheduled_date) + + def test_no_reply(self): + """ + Now we will check the not reply validation. To remember: + if it is not opened, the schedule date of the child task will be false + """ + with self.mock_mail_gateway(): + activity = self.create_mail_activity() + child_activity = self.create_mail_activity( + parent_id=activity.id, trigger_type="mail_not_reply" + ) + self.configuration.domain = "[('id', '=', %s)]" % self.partner_01.id + self.configuration.start_automation() + self.env["automation.configuration"].cron_automation() + self.env["automation.record.activity"]._cron_automation_activities() + record_activity = self.env["automation.record.activity"].search( + [("configuration_activity_id", "=", activity.id)] + ) + record_child_activity = self.env["automation.record.activity"].search( + [("configuration_activity_id", "=", child_activity.id)] + ) + self.assertEqual("sent", record_activity.mail_status) + self.assertTrue(record_child_activity) + self.assertFalse(record_child_activity.scheduled_date) + self.url_open(record_activity._get_mail_tracking_url()) + self.assertEqual("open", record_activity.mail_status) + self.assertTrue(record_child_activity.scheduled_date) + self.gateway_mail_reply_wrecord( + MAIL_TEMPLATE, self.partner_01, use_in_reply_to=True + ) + self.assertEqual("reply", record_activity.mail_status) + self.env["automation.record.activity"]._cron_automation_activities() + self.assertEqual("rejected", record_child_activity.state) + + def test_open(self): + """ + Now we will check the execution of scheduled activities""" + with self.mock_mail_gateway(): + activity = self.create_mail_activity() + child_activity = self.create_mail_activity( + parent_id=activity.id, trigger_type="mail_open" + ) + self.configuration.domain = "[('id', '=', %s)]" % self.partner_01.id + self.configuration.start_automation() + self.env["automation.configuration"].cron_automation() + self.env["automation.record.activity"]._cron_automation_activities() + record_activity = self.env["automation.record.activity"].search( + [("configuration_activity_id", "=", activity.id)] + ) + record_child_activity = self.env["automation.record.activity"].search( + [("configuration_activity_id", "=", child_activity.id)] + ) + self.assertEqual("sent", record_activity.mail_status) + self.assertTrue(record_child_activity) + self.assertFalse(record_child_activity.scheduled_date) + self.url_open(record_activity._get_mail_tracking_url()) + self.assertEqual("open", record_activity.mail_status) + self.assertTrue(record_child_activity.scheduled_date) + + def test_open_wrong_code(self): + """ + We wan to ensure that the code is checked on the call + """ + with self.mock_mail_gateway(): + activity = self.create_mail_activity() + child_activity = self.create_mail_activity( + parent_id=activity.id, trigger_type="mail_open" + ) + self.configuration.domain = "[('id', '=', %s)]" % self.partner_01.id + self.configuration.start_automation() + self.env["automation.configuration"].cron_automation() + self.env["automation.record.activity"]._cron_automation_activities() + record_activity = self.env["automation.record.activity"].search( + [("configuration_activity_id", "=", activity.id)] + ) + record_child_activity = self.env["automation.record.activity"].search( + [("configuration_activity_id", "=", child_activity.id)] + ) + self.assertEqual("sent", record_activity.mail_status) + self.assertTrue(record_child_activity) + self.assertFalse(record_child_activity.scheduled_date) + self.url_open( + "/automation_oca/track/%s/INVENTED_CODE/blank.gif" % record_activity.id + ) + self.assertEqual("sent", record_activity.mail_status) + self.assertFalse(record_child_activity.scheduled_date) + + def test_no_open(self): + """ + Now we will check the not open validation when it is not opened (should be executed) + """ + with self.mock_mail_gateway(): + activity = self.create_mail_activity() + child_activity = self.create_mail_activity( + parent_id=activity.id, trigger_type="mail_not_open" + ) + self.configuration.domain = "[('id', '=', %s)]" % self.partner_01.id + self.configuration.start_automation() + self.env["automation.configuration"].cron_automation() + self.env["automation.record.activity"]._cron_automation_activities() + record_activity = self.env["automation.record.activity"].search( + [("configuration_activity_id", "=", activity.id)] + ) + record_child_activity = self.env["automation.record.activity"].search( + [("configuration_activity_id", "=", child_activity.id)] + ) + self.assertEqual("sent", record_activity.mail_status) + self.assertTrue(record_child_activity) + self.assertTrue(record_child_activity.scheduled_date) + self.env["automation.record.activity"]._cron_automation_activities() + self.assertEqual("done", record_child_activity.state) + + def test_no_open_rejected(self): + """ + Now we will check the not open validation when it was already opened + """ + with self.mock_mail_gateway(): + activity = self.create_mail_activity() + child_activity = self.create_mail_activity( + parent_id=activity.id, trigger_type="mail_not_open" + ) + self.configuration.domain = "[('id', '=', %s)]" % self.partner_01.id + self.configuration.start_automation() + self.env["automation.configuration"].cron_automation() + self.env["automation.record.activity"]._cron_automation_activities() + record_activity = self.env["automation.record.activity"].search( + [("configuration_activity_id", "=", activity.id)] + ) + record_child_activity = self.env["automation.record.activity"].search( + [("configuration_activity_id", "=", child_activity.id)] + ) + self.assertEqual("sent", record_activity.mail_status) + self.assertTrue(record_child_activity) + self.assertTrue(record_child_activity.scheduled_date) + self.url_open(record_activity._get_mail_tracking_url()) + self.assertEqual("open", record_activity.mail_status) + self.env["automation.record.activity"]._cron_automation_activities() + self.assertEqual("rejected", record_child_activity.state)