You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
1.1 KiB

6 years ago
6 years ago
6 years ago
  1. # Copyright (C) 2019 Akretion (<http://www.akretion.com>)
  2. # @author: Florian da Costa
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from odoo.tests.common import TransactionCase
  5. from odoo import SUPERUSER_ID
  6. class TestExportSqlQueryMail(TransactionCase):
  7. def setUp(self):
  8. super(TestExportSqlQueryMail, self).setUp()
  9. self.sql_report_demo = self.env.ref('sql_export.sql_export_partner')
  10. self.sql_report_demo.write({'mail_user_ids': [(4, SUPERUSER_ID)]})
  11. def test_sql_query_mail(self):
  12. mail_obj = self.env['mail.mail']
  13. mails = mail_obj.search(
  14. [('model', '=', 'sql.export'),
  15. ('res_id', '=', self.sql_report_demo.id)])
  16. self.assertFalse(mails)
  17. self.sql_report_demo.create_cron()
  18. self.assertTrue(self.sql_report_demo.cron_ids)
  19. self.sql_report_demo.cron_ids.method_direct_trigger()
  20. mails = mail_obj.search(
  21. [('model', '=', 'sql.export'),
  22. ('res_id', '=', self.sql_report_demo.id)])
  23. self.assertTrue(mails)
  24. self.assertTrue(mails.attachment_ids)