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:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user