diff --git a/server/config/settings/test.py b/server/config/settings/test.py index ed59a58d..90c4b66c 100644 --- a/server/config/settings/test.py +++ b/server/config/settings/test.py @@ -39,7 +39,7 @@ MIGRATION_MODULES = DisableMigrations() DATABASES = { "default": { "ENGINE": "django.db.backends.postgresql_psycopg2", - "NAME": "vbv_lernwelt", + "NAME": "vbv_lernwelt_test", "USER": os.environ.get("PG_USER", getpass.getuser()), "PASSWORD": os.environ.get("PG_PASSWORD"), "HOST": "localhost", @@ -47,5 +47,6 @@ DATABASES = { } } + # Your stuff... # ------------------------------------------------------------------------------ diff --git a/server/vbv_lernwelt/learnpath/tests/create_default_learning_path.py b/server/vbv_lernwelt/learnpath/tests/create_default_learning_path.py index 93af9ce6..ab2c5144 100644 --- a/server/vbv_lernwelt/learnpath/tests/create_default_learning_path.py +++ b/server/vbv_lernwelt/learnpath/tests/create_default_learning_path.py @@ -3,7 +3,4 @@ from vbv_lernwelt.learnpath.tests.learningpath_factories import LearningPathFact def create_default_learning_path(): - - lp = LearningPath() - lp.save() - #lp = LearningPathFactory() + lp = LearningPathFactory() diff --git a/server/vbv_lernwelt/learnpath/tests/learningpath_factories.py b/server/vbv_lernwelt/learnpath/tests/learningpath_factories.py index a029e3c6..cb85cd85 100644 --- a/server/vbv_lernwelt/learnpath/tests/learningpath_factories.py +++ b/server/vbv_lernwelt/learnpath/tests/learningpath_factories.py @@ -4,5 +4,7 @@ from vbv_lernwelt.learnpath.models import LearningPath class LearningPathFactory(wagtail_factories.PageFactory): + title = "Versicherungsvermittler/in" + class Meta: model = LearningPath diff --git a/server/vbv_lernwelt/learnpath/tests/test_create_default_learning_path.py b/server/vbv_lernwelt/learnpath/tests/test_create_default_learning_path.py index 6762a4a6..c7fafd50 100644 --- a/server/vbv_lernwelt/learnpath/tests/test_create_default_learning_path.py +++ b/server/vbv_lernwelt/learnpath/tests/test_create_default_learning_path.py @@ -1,16 +1,21 @@ +from django.conf import settings from django.test import TestCase -import locale +from wagtail.core.models import Locale + from vbv_lernwelt.learnpath.models import LearningPath from vbv_lernwelt.learnpath.tests.create_default_learning_path import create_default_learning_path -from django.utils.translation import to_locale, get_language class TestCreateDefaultLearningPaths(TestCase): - def test_create_learning_path(self): - print(locale.getdefaultlocale()) - print(to_locale(get_language())) + def setUp(self) -> None: + create_locales_for_wagtail() + def test_create_learning_path(self): create_default_learning_path() qs = LearningPath.objects.filter(title="Versicherungsvermittler/in") self.assertTrue(qs.exists()) + +def create_locales_for_wagtail(): + for language in settings.WAGTAIL_CONTENT_LANGUAGES: + Locale.objects.create(language_code=language[0])