Update migrations to accept migrated settings
- Unify all conditional YAML load under utils.smart_yaml_load. - Update all setting migrations to use the smart setting test mixin to create the test config file. Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
Rob de Canha-Knight (@rssfed23) for the report and the research.
|
||||
- Update instances of the word "weblink" to "web link".
|
||||
- Unify the creation of the temporary config file used in tests.
|
||||
- Update all 0001 setting migrations to not accept manually migrated
|
||||
settings.
|
||||
|
||||
3.3.4 (2019-12-09)
|
||||
==================
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from mayan.apps.smart_settings.classes import NamespaceMigration
|
||||
|
||||
from .serialization import yaml_load
|
||||
from mayan.apps.smart_settings.utils import smart_yaml_load
|
||||
|
||||
|
||||
class CommonSettingMigration(NamespaceMigration):
|
||||
@@ -11,6 +10,4 @@ class CommonSettingMigration(NamespaceMigration):
|
||||
but YAML valid too. Changed in version 3.3.
|
||||
"""
|
||||
def common_shared_storage_arguments_0001(self, value):
|
||||
return yaml_load(
|
||||
stream=value or '{}',
|
||||
)
|
||||
return smart_yaml_load(value=value)
|
||||
|
||||
@@ -1,35 +1,30 @@
|
||||
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 mayan.apps.smart_settings.tests.mixins import SmartSettingTestMixin
|
||||
|
||||
from ..settings import setting_shared_storage_arguments
|
||||
|
||||
|
||||
class CommonSettingMigrationTestCase(EnvironmentTestCaseMixin, BaseTestCase):
|
||||
class CommonSettingMigrationTestCase(SmartSettingTestMixin, BaseTestCase):
|
||||
def test_common_shared_storage_arguments_0001_migration(self):
|
||||
|
||||
test_value = {'location': 'test value'}
|
||||
self.test_setting = setting_shared_storage_arguments
|
||||
self.test_config_value = '{}'.format(test_value)
|
||||
self._create_test_config_file()
|
||||
|
||||
with NamedTemporaryFile() as file_object:
|
||||
settings.CONFIGURATION_FILEPATH = file_object.name
|
||||
file_object.write(
|
||||
force_bytes(
|
||||
'{}: {}'.format(
|
||||
'COMMON_SHARED_STORAGE_ARGUMENTS',
|
||||
'"{}"'.format(Setting.serialize_value(value=test_value))
|
||||
)
|
||||
)
|
||||
)
|
||||
file_object.seek(0)
|
||||
Setting._config_file_cache = None
|
||||
self.assertEqual(
|
||||
setting_shared_storage_arguments.value,
|
||||
test_value
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
setting_shared_storage_arguments.value,
|
||||
test_value
|
||||
)
|
||||
def test_common_shared_storage_arguments_0001_migration_with_dict(self):
|
||||
test_value = {'location': 'test value'}
|
||||
self.test_setting = setting_shared_storage_arguments
|
||||
self.test_config_value = test_value
|
||||
self._create_test_config_file()
|
||||
|
||||
self.assertEqual(
|
||||
setting_shared_storage_arguments.value,
|
||||
test_value
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from mayan.apps.common.serialization import yaml_load
|
||||
from mayan.apps.smart_settings.classes import NamespaceMigration
|
||||
from mayan.apps.smart_settings.utils import smart_yaml_load
|
||||
|
||||
|
||||
class ConvertSettingMigration(NamespaceMigration):
|
||||
@@ -10,6 +10,4 @@ class ConvertSettingMigration(NamespaceMigration):
|
||||
but YAML valid too. Changed in version 3.3.
|
||||
"""
|
||||
def converter_graphics_backend_arguments_0001(self, value):
|
||||
return yaml_load(
|
||||
stream=value or '{}',
|
||||
)
|
||||
return smart_yaml_load(value=value)
|
||||
|
||||
@@ -1,39 +1,32 @@
|
||||
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 mayan.apps.smart_settings.tests.mixins import SmartSettingTestMixin
|
||||
|
||||
from ..settings import setting_graphics_backend_arguments
|
||||
|
||||
|
||||
class ConverterSettingMigrationTestCase(
|
||||
EnvironmentTestCaseMixin, BaseTestCase
|
||||
SmartSettingTestMixin, BaseTestCase
|
||||
):
|
||||
def test_converter_graphics_backend_arguments_0001_migration(self):
|
||||
|
||||
test_value = {'location': 'test value'}
|
||||
self.test_setting = setting_graphics_backend_arguments
|
||||
self.test_config_value = '{}'.format(test_value)
|
||||
self._create_test_config_file()
|
||||
|
||||
with NamedTemporaryFile() as file_object:
|
||||
settings.CONFIGURATION_FILEPATH = file_object.name
|
||||
file_object.write(
|
||||
force_bytes(
|
||||
'{}: {}'.format(
|
||||
'CONVERTER_GRAPHICS_BACKEND_ARGUMENTS',
|
||||
'"{}"'.format(
|
||||
Setting.serialize_value(value=test_value)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
file_object.seek(0)
|
||||
Setting._config_file_cache = None
|
||||
self.assertEqual(
|
||||
setting_graphics_backend_arguments.value,
|
||||
test_value
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
setting_graphics_backend_arguments.value,
|
||||
test_value
|
||||
)
|
||||
def test_converter_graphics_backend_arguments_0001_migration_with_dict(self):
|
||||
test_value = {'location': 'test value'}
|
||||
self.test_setting = setting_graphics_backend_arguments
|
||||
self.test_config_value = test_value
|
||||
self._create_test_config_file()
|
||||
|
||||
self.assertEqual(
|
||||
setting_graphics_backend_arguments.value,
|
||||
test_value
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from mayan.apps.common.serialization import yaml_load
|
||||
from mayan.apps.smart_settings.classes import NamespaceMigration
|
||||
from mayan.apps.smart_settings.utils import smart_yaml_load
|
||||
|
||||
|
||||
class DocumentSignaturesSettingMigration(NamespaceMigration):
|
||||
@@ -10,6 +10,4 @@ class DocumentSignaturesSettingMigration(NamespaceMigration):
|
||||
but YAML valid too. Changed in version 3.3.
|
||||
"""
|
||||
def signatures_storage_backend_arguments_0001(self, value):
|
||||
return yaml_load(
|
||||
stream=value or '{}',
|
||||
)
|
||||
return smart_yaml_load(value=value)
|
||||
|
||||
@@ -1,39 +1,32 @@
|
||||
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 mayan.apps.smart_settings.tests.mixins import SmartSettingTestMixin
|
||||
|
||||
from ..settings import setting_storage_backend_arguments
|
||||
|
||||
|
||||
class DocumentSignaturesSettingMigrationTestCase(
|
||||
EnvironmentTestCaseMixin, BaseTestCase
|
||||
SmartSettingTestMixin, BaseTestCase
|
||||
):
|
||||
def test_signatures_storage_backend_arguments_0001_migration(self):
|
||||
|
||||
test_value = {'location': 'test value'}
|
||||
self.test_setting = setting_storage_backend_arguments
|
||||
self.test_config_value = '{}'.format(test_value)
|
||||
self._create_test_config_file()
|
||||
|
||||
with NamedTemporaryFile() as file_object:
|
||||
settings.CONFIGURATION_FILEPATH = file_object.name
|
||||
file_object.write(
|
||||
force_bytes(
|
||||
'{}: {}'.format(
|
||||
'SIGNATURES_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
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
setting_storage_backend_arguments.value,
|
||||
test_value
|
||||
)
|
||||
def test_signatures_storage_backend_arguments_0001_migration_with_dict(self):
|
||||
test_value = {'location': 'test value'}
|
||||
self.test_setting = setting_storage_backend_arguments
|
||||
self.test_config_value = test_value
|
||||
self._create_test_config_file()
|
||||
|
||||
self.assertEqual(
|
||||
setting_storage_backend_arguments.value,
|
||||
test_value
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from mayan.apps.common.serialization import yaml_load
|
||||
from mayan.apps.smart_settings.classes import NamespaceMigration
|
||||
from mayan.apps.smart_settings.utils import smart_yaml_load
|
||||
|
||||
|
||||
class DocumentsSettingMigration(NamespaceMigration):
|
||||
@@ -10,11 +10,7 @@ class DocumentsSettingMigration(NamespaceMigration):
|
||||
but YAML valid too. Changed in version 3.3.
|
||||
"""
|
||||
def documents_cache_storage_backend_arguments_0001(self, value):
|
||||
return yaml_load(
|
||||
stream=value or '{}',
|
||||
)
|
||||
return smart_yaml_load(value=value)
|
||||
|
||||
def documents_storage_backend_arguments_0001(self, value):
|
||||
return yaml_load(
|
||||
stream=value or '{}',
|
||||
)
|
||||
return smart_yaml_load(value=value)
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
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 mayan.apps.smart_settings.tests.mixins import SmartSettingTestMixin
|
||||
|
||||
from ..settings import (
|
||||
setting_documentimagecache_storage_arguments,
|
||||
@@ -14,49 +9,47 @@ from ..settings import (
|
||||
)
|
||||
|
||||
|
||||
class DocumentSettingMigrationTestCase(EnvironmentTestCaseMixin, BaseTestCase):
|
||||
class DocumentSettingMigrationTestCase(SmartSettingTestMixin, BaseTestCase):
|
||||
def test_documents_storage_backend_arguments_0001(self):
|
||||
test_value = {'location': 'test value'}
|
||||
self.test_setting = setting_documentimagecache_storage_arguments
|
||||
self.test_config_value = '{}'.format(test_value)
|
||||
self._create_test_config_file()
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
setting_documentimagecache_storage_arguments.value,
|
||||
test_value
|
||||
)
|
||||
def test_documents_storage_backend_arguments_0001_with_dict(self):
|
||||
test_value = {'location': 'test value'}
|
||||
self.test_setting = setting_documentimagecache_storage_arguments
|
||||
self.test_config_value = test_value
|
||||
self._create_test_config_file()
|
||||
|
||||
self.assertEqual(
|
||||
setting_documentimagecache_storage_arguments.value,
|
||||
test_value
|
||||
)
|
||||
|
||||
def test_documents_cache_storage_backend_arguments_0001(self):
|
||||
test_value = {'location': 'test value'}
|
||||
self.test_setting = setting_storage_backend_arguments
|
||||
self.test_config_value = '{}'.format(test_value)
|
||||
self._create_test_config_file()
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
setting_storage_backend_arguments.value,
|
||||
test_value
|
||||
)
|
||||
def test_documents_cache_storage_backend_arguments_0001_with_dict(self):
|
||||
test_value = {'location': 'test value'}
|
||||
self.test_setting = setting_storage_backend_arguments
|
||||
self.test_config_value = test_value
|
||||
self._create_test_config_file()
|
||||
|
||||
self.assertEqual(
|
||||
setting_storage_backend_arguments.value,
|
||||
test_value
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from mayan.apps.common.serialization import yaml_load
|
||||
from mayan.apps.smart_settings.classes import NamespaceMigration
|
||||
from mayan.apps.smart_settings.utils import smart_yaml_load
|
||||
|
||||
|
||||
class FileMetadataSettingMigration(NamespaceMigration):
|
||||
@@ -10,6 +10,4 @@ class FileMetadataSettingMigration(NamespaceMigration):
|
||||
but YAML valid too. Changed in version 3.3.
|
||||
"""
|
||||
def file_metadata_drivers_arguments_0001(self, value):
|
||||
return yaml_load(
|
||||
stream=value or '{}',
|
||||
)
|
||||
return smart_yaml_load(value=value)
|
||||
|
||||
@@ -1,39 +1,32 @@
|
||||
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 mayan.apps.smart_settings.tests.mixins import SmartSettingTestMixin
|
||||
|
||||
from ..settings import setting_drivers_arguments
|
||||
|
||||
|
||||
class FileMetadataSettingMigrationTestCase(
|
||||
EnvironmentTestCaseMixin, BaseTestCase
|
||||
SmartSettingTestMixin, BaseTestCase
|
||||
):
|
||||
def test_file_metadata_drivers_arguments_0001_migration(self):
|
||||
|
||||
test_value = {'location': 'test value'}
|
||||
self.test_setting = setting_drivers_arguments
|
||||
self.test_config_value = '{}'.format(test_value)
|
||||
self._create_test_config_file()
|
||||
|
||||
with NamedTemporaryFile() as file_object:
|
||||
settings.CONFIGURATION_FILEPATH = file_object.name
|
||||
file_object.write(
|
||||
force_bytes(
|
||||
'{}: {}'.format(
|
||||
'FILE_METADATA_DRIVERS_ARGUMENTS',
|
||||
'"{}"'.format(
|
||||
Setting.serialize_value(value=test_value)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
file_object.seek(0)
|
||||
Setting._config_file_cache = None
|
||||
self.assertEqual(
|
||||
setting_drivers_arguments.value,
|
||||
test_value
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
setting_drivers_arguments.value,
|
||||
test_value
|
||||
)
|
||||
def test_file_metadata_drivers_arguments_0001_migration_with_dict(self):
|
||||
test_value = {'location': 'test value'}
|
||||
self.test_setting = setting_drivers_arguments
|
||||
self.test_config_value = test_value
|
||||
self._create_test_config_file()
|
||||
|
||||
self.assertEqual(
|
||||
setting_drivers_arguments.value,
|
||||
test_value
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from mayan.apps.common.serialization import yaml_load
|
||||
from mayan.apps.smart_settings.classes import NamespaceMigration
|
||||
from mayan.apps.smart_settings.utils import smart_yaml_load
|
||||
|
||||
|
||||
class OCRSettingMigration(NamespaceMigration):
|
||||
@@ -10,6 +10,4 @@ class OCRSettingMigration(NamespaceMigration):
|
||||
but YAML valid too. Changed in version 3.3.
|
||||
"""
|
||||
def ocr_backend_arguments_0001(self, value):
|
||||
return yaml_load(
|
||||
stream=value or '{}',
|
||||
)
|
||||
return smart_yaml_load(value=value)
|
||||
|
||||
@@ -1,36 +1,28 @@
|
||||
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 mayan.apps.smart_settings.tests.mixins import SmartSettingTestMixin
|
||||
|
||||
from ..settings import setting_ocr_backend_arguments
|
||||
|
||||
|
||||
class OCRSettingMigrationTestCase(EnvironmentTestCaseMixin, BaseTestCase):
|
||||
class OCRSettingMigrationTestCase(SmartSettingTestMixin, BaseTestCase):
|
||||
def test_ocr_backend_arguments_0001(self):
|
||||
|
||||
test_value = {'location': 'test value'}
|
||||
self.test_setting = setting_ocr_backend_arguments
|
||||
self.test_config_value = '{}'.format(test_value)
|
||||
self._create_test_config_file()
|
||||
|
||||
with NamedTemporaryFile() as file_object:
|
||||
settings.CONFIGURATION_FILEPATH = file_object.name
|
||||
file_object.write(
|
||||
force_bytes(
|
||||
'{}: {}'.format(
|
||||
'OCR_BACKEND_ARGUMENTS',
|
||||
'"{}"'.format(
|
||||
Setting.serialize_value(value=test_value)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
file_object.seek(0)
|
||||
Setting._config_file_cache = None
|
||||
self.assertEqual(
|
||||
setting_ocr_backend_arguments.value, test_value
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
setting_ocr_backend_arguments.value, test_value
|
||||
)
|
||||
def test_ocr_backend_arguments_0001_with_dict(self):
|
||||
test_value = {'location': 'test value'}
|
||||
self.test_setting = setting_ocr_backend_arguments
|
||||
self.test_config_value = test_value
|
||||
self._create_test_config_file()
|
||||
|
||||
self.assertEqual(
|
||||
setting_ocr_backend_arguments.value, test_value
|
||||
)
|
||||
|
||||
@@ -3,6 +3,7 @@ from __future__ import absolute_import, unicode_literals
|
||||
from django.conf import settings
|
||||
from django.utils.encoding import force_bytes
|
||||
|
||||
from mayan.apps.common.tests.mixins import EnvironmentTestCaseMixin
|
||||
from mayan.apps.storage.utils import fs_cleanup, NamedTemporaryFile
|
||||
|
||||
from ..classes import Namespace, Setting
|
||||
@@ -36,7 +37,7 @@ class SmartSettingsTestCaseMixin(object):
|
||||
Namespace.invalidate_cache_all()
|
||||
|
||||
|
||||
class SmartSettingTestMixin(object):
|
||||
class SmartSettingTestMixin(EnvironmentTestCaseMixin):
|
||||
test_setting_global_name = None
|
||||
test_config_file_object = None
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import os
|
||||
|
||||
import yaml
|
||||
|
||||
from mayan.apps.common.compat import dict_type
|
||||
from mayan.apps.common.serialization import yaml_load
|
||||
|
||||
from .literals import (
|
||||
@@ -219,6 +220,15 @@ class MediaBootstrapSetting(FilesystemBootstrapSetting):
|
||||
)
|
||||
|
||||
|
||||
def smart_yaml_load(value):
|
||||
if isinstance(value, dict_type):
|
||||
return value
|
||||
else:
|
||||
return yaml_load(
|
||||
stream=value or '{}',
|
||||
)
|
||||
|
||||
|
||||
# FilesystemBootstrapSetting settings
|
||||
|
||||
SettingNamespaceSingleton.register_setting(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from mayan.apps.common.serialization import yaml_load
|
||||
from mayan.apps.smart_settings.classes import NamespaceMigration
|
||||
from mayan.apps.smart_settings.utils import smart_yaml_load
|
||||
|
||||
|
||||
class SourcesSettingMigration(NamespaceMigration):
|
||||
@@ -10,6 +10,4 @@ class SourcesSettingMigration(NamespaceMigration):
|
||||
but YAML valid too. Changed in version 3.3.
|
||||
"""
|
||||
def sources_staging_file_cache_storage_backend_arguments_0001(self, value):
|
||||
return yaml_load(
|
||||
stream=value or '{}',
|
||||
)
|
||||
return smart_yaml_load(value=value)
|
||||
|
||||
@@ -1,35 +1,33 @@
|
||||
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 mayan.apps.smart_settings.tests.mixins import SmartSettingTestMixin
|
||||
|
||||
from ..settings import setting_staging_file_image_cache_storage_arguments
|
||||
|
||||
|
||||
class SourceSettingMigrationTestCase(EnvironmentTestCaseMixin, BaseTestCase):
|
||||
class SourceSettingMigrationTestCase(
|
||||
SmartSettingTestMixin, BaseTestCase
|
||||
):
|
||||
def test_setting_staging_file_image_cache_storage_arguments_0001_migration(self):
|
||||
test_value = {'location': 'test value'}
|
||||
self.test_setting = setting_staging_file_image_cache_storage_arguments
|
||||
self.test_config_value = '{}'.format(test_value)
|
||||
self._create_test_config_file()
|
||||
|
||||
self.assertEqual(
|
||||
setting_staging_file_image_cache_storage_arguments.value,
|
||||
test_value
|
||||
)
|
||||
|
||||
def test_setting_staging_file_image_cache_storage_arguments_0001_migration_with_dict(self):
|
||||
test_value = {'location': 'test value'}
|
||||
|
||||
with NamedTemporaryFile() as file_object:
|
||||
settings.CONFIGURATION_FILEPATH = file_object.name
|
||||
file_object.write(
|
||||
force_bytes(
|
||||
'{}: {}'.format(
|
||||
'SOURCES_STAGING_FILE_CACHE_STORAGE_BACKEND_ARGUMENTS',
|
||||
'"{}"'.format(Setting.serialize_value(value=test_value))
|
||||
)
|
||||
)
|
||||
)
|
||||
file_object.seek(0)
|
||||
Setting._config_file_cache = None
|
||||
self.test_setting = setting_staging_file_image_cache_storage_arguments
|
||||
self.test_config_value = test_value
|
||||
self._create_test_config_file()
|
||||
|
||||
self.assertEqual(
|
||||
setting_staging_file_image_cache_storage_arguments.value,
|
||||
test_value
|
||||
)
|
||||
self.assertEqual(
|
||||
setting_staging_file_image_cache_storage_arguments.value,
|
||||
test_value
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user