schon/engine/core/tests/test_drf.py
Egor fureunoir Gorbunov 43dc556063 Features: 1) Migrate from Jazzmin to django-unfold for admin UI;
Fixes: 1) Remove deprecated Jazzmin configuration and replace with unfold dependencies; 2) Update DRF API title to use new PROJECT_NAME; 3) Fix import order and remove unused imports in core/viewsets.py;

Extra: 1) Add PROJECT_NAME to base settings; 2) Update INSTALLED_APPS to include unfold-related apps; 3) Clean up unused config references.
2025-11-15 01:38:14 +03:00

34 lines
1.2 KiB
Python

from django.test import TestCase
from rest_framework.test import APIClient
from engine.vibes_auth.models import User
from engine.vibes_auth.serializers import TokenObtainPairSerializer
class DRFCoreViewsTests(TestCase):
def setUp(self):
super().setUp()
self.client = APIClient()
self.superuser_password = "Str0ngPass!word1"
self.superuser = User.objects.create(
email="test-superuser@email.com",
password=self.superuser_password,
is_active=True,
is_verified=True,
is_superuser=True,
is_staff=True,
)
self.user_password = "Str0ngPass!word2"
self.user = User.objects.create(
email="test-superuser@email.com", password=self.user_password, is_active=True, is_verified=True
)
def _get_authorization_token(self, user):
serializer = TokenObtainPairSerializer(
data={"email": user.email, "password": self.superuser_password if user.is_superuser else self.user_password}
)
serializer.is_valid(raise_exception=True)
return serializer.validated_data["access_token"]
# TODO: create tests for every possible HTTP method in core module with DRF stack