from django.test import TestCase, RequestFactory
from graphene.test import Client

from api.schema import schema
from users.models import User
from users.services import create_users


class SkillboxTestCase(TestCase):
    def createDefault(self) -> None:
        create_users()
        self.teacher = User.objects.get(username='teacher')
        self.teacher2 = User.objects.get(username='teacher2')
        self.student1 = User.objects.get(username='student1')
        self.student2 = User.objects.get(username='student2')
        self.student_second_class = User.objects.get(username='student_second_class')

    def get_client(self, user=None) -> Client:
        request = RequestFactory().get('/')
        if user is None:
            user = self.teacher
        request.user = user
        return Client(schema=schema, context_value=request)
