diff --git a/HISTORY.rst b/HISTORY.rst index 76d0cf8f01..d30f2eb105 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -2,6 +2,7 @@ ================== - Improve setting migration method matching. Avoid executing a migrations for settings with similar but shorter names. +- Fix sources app setting migrations. 3.3.1 (2019-12-04) ================== diff --git a/mayan/apps/sources/setting_migrations.py b/mayan/apps/sources/setting_migrations.py index ee99216a14..40af240d56 100644 --- a/mayan/apps/sources/setting_migrations.py +++ b/mayan/apps/sources/setting_migrations.py @@ -9,7 +9,7 @@ class SourcesSettingMigration(NamespaceMigration): From version 0001 to 0002 backend arguments are no longer quoted but YAML valid too. Changed in version 3.3. """ - def sources_staging_file_cache_storage_backend_arguments(self, value): + def sources_staging_file_cache_storage_backend_arguments_0001(self, value): return yaml_load( stream=value or '{}', ) diff --git a/mayan/apps/sources/tests/test_setting_migrations.py b/mayan/apps/sources/tests/test_setting_migrations.py new file mode 100644 index 0000000000..5d748bdbe8 --- /dev/null +++ b/mayan/apps/sources/tests/test_setting_migrations.py @@ -0,0 +1,35 @@ +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_staging_file_image_cache_storage_arguments + + +class SourceSettingMigrationTestCase(EnvironmentTestCaseMixin, BaseTestCase): + def test_setting_staging_file_image_cache_storage_arguments_0001_migration(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.assertEqual( + setting_staging_file_image_cache_storage_arguments.value, + test_value + )