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.

59 lines
2.3 KiB

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