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.

39 lines
1.3 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  2. import odoo
  3. from odoo import api
  4. from odoo.tests.common import TransactionCase
  5. class TestAttachmentBaseQueue(TransactionCase):
  6. def setUp(self):
  7. super().setUp()
  8. self.registry.enter_test_mode(self.env.cr)
  9. self.env = api.Environment(
  10. self.registry.test_cr, self.env.uid, self.env.context
  11. )
  12. self.attachment = self.env.ref(
  13. "attachment_queue.attachment_queue_demo"
  14. )
  15. def tearDown(self):
  16. self.registry.leave_test_mode()
  17. super().tearDown()
  18. def test_attachment_queue(self):
  19. """Test run_attachment_queue_scheduler to ensure set state to done
  20. """
  21. self.assertEqual(self.attachment.state, "pending")
  22. self.env["attachment.queue"].run_attachment_queue_scheduler()
  23. self.env.cache.invalidate()
  24. with odoo.registry(self.env.cr.dbname).cursor() as new_cr:
  25. new_env = api.Environment(new_cr, self.env.uid, self.env.context)
  26. attach = self.attachment.with_env(new_env)
  27. self.assertEqual(attach.state, "done")
  28. def test_set_done(self):
  29. """Test set_done manually
  30. """
  31. self.assertEqual(self.attachment.state, "pending")
  32. self.attachment.set_done()
  33. self.assertEqual(self.attachment.state, "done")