test_audit.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # OpenERP, Open Source Management Solution
  5. # Copyright (C) 2010 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Affero General Public License as
  9. # published by the Free Software Foundation, either version 3 of the
  10. # License, or (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Affero General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Affero General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. ##############################################################################
  21. from openerp.tests import common
  22. class TestModelAudit(common.TransactionCase):
  23. def test_get_action_url(self):
  24. """Test if action url start with http."""
  25. record = self.env.ref("mgmtsystem_audit.mgmtsystem_audit_demo")
  26. ret = record.get_action_url()
  27. self.assertEqual(isinstance(ret, basestring), True)
  28. self.assertEqual(ret.startswith('http'), True)
  29. def test_button_close(self):
  30. """Test if button close change audit state to close."""
  31. record = self.env.ref("mgmtsystem_audit.mgmtsystem_audit_demo")
  32. record.state = "open"
  33. self.assertEqual(record.state, "open")
  34. record.button_close()
  35. self.assertEqual(record.state, "done")
  36. def test_get_lines_by_procedure(self):
  37. line_id = self.env["mgmtsystem.verification.line"].create({
  38. "name": "test",
  39. "procedure_id": self.env.ref("document_page.demo_page1").id
  40. })
  41. line_id2 = self.env["mgmtsystem.verification.line"].create({
  42. "name": "test2",
  43. })
  44. record = self.env.ref("mgmtsystem_audit.mgmtsystem_audit_demo")
  45. record.line_ids = [line_id.id, line_id2.id]
  46. q = record.get_lines_by_procedure()
  47. self.assertTrue(q)