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.

43 lines
1.4 KiB

5 years ago
5 years ago
5 years ago
  1. # Copyright 2020 Akretion (http://www.akretion.com).
  2. # @author Sébastien BEAU <sebastien.beau@akretion.com>
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  4. import mock
  5. import os
  6. from odoo.addons.storage_backend.tests.common import Common
  7. class SyncCommon(Common):
  8. def _clean_testing_directory(self):
  9. for test_dir in [
  10. self.directory_input,
  11. self.directory_output,
  12. self.directory_archived,
  13. ]:
  14. for filename in self.backend._list(test_dir):
  15. self.backend._delete(os.path.join(test_dir, filename))
  16. def _create_test_file(self):
  17. self.backend._add_b64_data(
  18. os.path.join(self.directory_input, "bar.txt"),
  19. self.filedata,
  20. mimetype=u"text/plain",
  21. )
  22. def setUp(self):
  23. super().setUp()
  24. self.env.cr.commit = mock.Mock()
  25. self.registry.enter_test_mode(self.env.cr)
  26. self.directory_input = "test_import"
  27. self.directory_output = "test_export"
  28. self.directory_archived = "test_archived"
  29. self._clean_testing_directory()
  30. self._create_test_file()
  31. self.task = self.env.ref(
  32. "attachment_synchronize.import_from_filestore"
  33. )
  34. def tearDown(self):
  35. self.registry.leave_test_mode()
  36. self._clean_testing_directory()
  37. super().tearDown()