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.

52 lines
1.6 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
  1. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  2. from odoo.tests.common import TransactionCase
  3. import odoo
  4. from odoo import api
  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(self.registry.test_cr, self.env.uid,
  10. self.env.context)
  11. self.attachment = self.env.ref(
  12. 'base_attachment_queue.attachment_metadata')
  13. self.ir_attachment_metadata = self.env['ir.attachment.metadata']
  14. def tearDown(self):
  15. self.registry.leave_test_mode()
  16. super().tearDown()
  17. def test_attachment_metadata(self):
  18. """Test run_attachment_metadata_scheduler to ensure set state to done
  19. """
  20. self.assertEqual(
  21. self.attachment.state,
  22. 'pending'
  23. )
  24. self.ir_attachment_metadata.run_attachment_metadata_scheduler()
  25. self.env.cache.invalidate()
  26. with odoo.registry(self.env.cr.dbname).cursor() as new_cr:
  27. new_env = api.Environment(
  28. new_cr, self.env.uid, self.env.context)
  29. attach = self.attachment.with_env(new_env)
  30. self.assertEqual(
  31. attach.state,
  32. 'done'
  33. )
  34. def test_set_done(self):
  35. """Test set_done manually
  36. """
  37. self.assertEqual(
  38. self.attachment.state,
  39. 'pending'
  40. )
  41. self.attachment.set_done()
  42. self.assertEqual(
  43. self.attachment.state,
  44. 'done'
  45. )