import pytest
from core.tests.base_test import GQLClient
from users.models import SchoolClass
from api.schema import schema
from core.tests.helpers import GQLResult

#
#
# @pytest.fixture(scope="session")
# def prefix():
#     return "Meine Klasse"

from users.services import create_users as _create_users


@pytest.fixture
def create_users():
    _create_users()


@pytest.fixture
def teacher(django_user_model):
    return django_user_model.objects.get(username="teacher")


@pytest.fixture
def teacher2(django_user_model):
    return django_user_model.objects.get(username="teacher2")


@pytest.fixture
def student1(django_user_model):
    return django_user_model.objects.get(username="student1")


@pytest.fixture
def student2(django_user_model):
    return django_user_model.objects.get(username="student2")


@pytest.fixture
def student_second_class(django_user_model):
    return django_user_model.objects.get(username="student_second_class")


@pytest.fixture
def school_class():
    return SchoolClass.objects.get(name="skillbox")


@pytest.fixture
def get_client(teacher, rf):
    def _get_client(user):
        request = rf.get("/")
        if user is None:
            user = teacher
        request.user = user
        return GQLClient(schema=schema, context_value=request)

    return _get_client
