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.

58 lines
2.2 KiB

  1. # Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  3. import base64
  4. import odoo.tests.common as common
  5. from .common import TestWizardCommon
  6. class TestImportHelpWizard(TestWizardCommon, common.TransactionCase):
  7. def setUp(self):
  8. super(TestImportHelpWizard, self).setUp()
  9. self.page_name = "export_import_help"
  10. self.img_xml_id = '%s.test_img_1' % self._module_ns
  11. self.img_name = self.env.ref(self.img_xml_id).name
  12. self.ir_attchement = self.env['ir.attachment']
  13. self.ir_ui_view = self.env['ir.ui.view']
  14. self.export_help_wizard = self.env['export.help.wizard']
  15. self.import_help_wizard = self.env['import.help.wizard']
  16. def _do_check_resources(self, expected=1):
  17. pages = self.ir_ui_view.search([('name', '=', self.page_name)])
  18. self.assertEqual(expected, len(pages))
  19. attachments = self.ir_attchement.search(
  20. [('name', '=', self.img_name)])
  21. self.assertEqual(expected, len(attachments))
  22. def test_import_help(self):
  23. self.createPage(pageName=self.page_name, imgXmlId=self.img_xml_id)
  24. self._do_check_resources()
  25. wizard = self.export_help_wizard.create({})
  26. wizard.export_help()
  27. xmlData = base64.decodestring(wizard.data)
  28. self.env.ref(self.img_xml_id).unlink()
  29. self.ir_ui_view.search([('name', '=', self.page_name)]).unlink()
  30. self._do_check_resources(0)
  31. wizard = self.import_help_wizard.create({
  32. 'source_file': base64.encodestring(xmlData)
  33. })
  34. wizard.import_help()
  35. self._do_check_resources()
  36. def test_import_export_help(self):
  37. """Check that exported data are not ducplicated by export / import
  38. """
  39. self.createPage(pageName=self.page_name, imgXmlId=self.img_xml_id)
  40. self._do_check_resources()
  41. # export
  42. wizard = self.export_help_wizard.create({})
  43. wizard.export_help()
  44. xmlData = base64.decodestring(wizard.data)
  45. self._do_check_resources()
  46. wizard = self.import_help_wizard.create({
  47. 'source_file': base64.encodestring(xmlData)
  48. })
  49. wizard.import_help()
  50. self._do_check_resources()