from django.conf import settings
from django.test import TestCase
from wagtail.models import Locale

from vbv_lernwelt.core.create_default_users import create_default_users
from vbv_lernwelt.learnpath.models import LearningPath
from vbv_lernwelt.learnpath.tests.create_default_learning_path import create_default_learning_path


class TestCreateDefaultLearningPaths(TestCase):
    def setUp(self) -> None:
        create_default_users()
        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.get_or_create(language_code=language[0])
