From 7a9333e44e7761107e42d3caa461bb53d3fa5b12 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Wed, 4 Dec 2019 23:21:22 -0400 Subject: [PATCH] Add documents app setting migration tests Signed-off-by: Roberto Rosario --- .../tests/test_setting_migrations.py | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 mayan/apps/documents/tests/test_setting_migrations.py diff --git a/mayan/apps/documents/tests/test_setting_migrations.py b/mayan/apps/documents/tests/test_setting_migrations.py new file mode 100644 index 0000000000..3690689323 --- /dev/null +++ b/mayan/apps/documents/tests/test_setting_migrations.py @@ -0,0 +1,62 @@ +from __future__ import unicode_literals + +from django.conf import settings +from django.utils.encoding import force_bytes + +from mayan.apps.common.tests.base import BaseTestCase +from mayan.apps.common.tests.mixins import EnvironmentTestCaseMixin +from mayan.apps.smart_settings.classes import Setting +from mayan.apps.storage.utils import NamedTemporaryFile + +from ..settings import ( + setting_documentimagecache_storage_arguments, + setting_storage_backend_arguments +) + + +class DocumentSettingMigrationTestCase(EnvironmentTestCaseMixin, BaseTestCase): + def test_documents_storage_backend_arguments_0001(self): + test_value = {'location': 'test value'} + + with NamedTemporaryFile() as file_object: + settings.CONFIGURATION_FILEPATH = file_object.name + file_object.write( + force_bytes( + '{}: {}'.format( + 'DOCUMENTS_CACHE_STORAGE_BACKEND_ARGUMENTS', + '"{}"'.format( + Setting.serialize_value(value=test_value) + ) + ) + ) + ) + file_object.seek(0) + Setting._config_file_cache = None + + self.assertEqual( + setting_documentimagecache_storage_arguments.value, + test_value + ) + + def test_documents_cache_storage_backend_arguments_0001(self): + test_value = {'location': 'test value'} + + with NamedTemporaryFile() as file_object: + settings.CONFIGURATION_FILEPATH = file_object.name + file_object.write( + force_bytes( + '{}: {}'.format( + 'DOCUMENTS_STORAGE_BACKEND_ARGUMENTS', + '"{}"'.format( + Setting.serialize_value(value=test_value) + ) + ) + ) + ) + file_object.seek(0) + Setting._config_file_cache = None + + self.assertEqual( + setting_storage_backend_arguments.value, + test_value + )