Implement exchange imports and frontend reporting APIs
Some checks failed
CI/CD Pipeline / Code Quality Checks (push) Failing after 3m50s
CI/CD Pipeline / Run Tests (push) Successful in 3m57s
CI/CD Pipeline / Build Docker Images (push) Has been skipped
CI/CD Pipeline / Push to Gitea Registry (push) Has been skipped
CI/CD Pipeline / Deploy to Server (push) Has been skipped

This commit is contained in:
2026-04-07 16:31:04 +02:00
parent 76a86d0b20
commit 697ecb7d1c
155 changed files with 5604 additions and 346 deletions

View File

@@ -1,13 +1,14 @@
"""Tests for user DRF views"""
from apps.user.models import Profile
from apps.user.services import UserService
from django.contrib.auth import get_user_model
from django.urls import reverse
from faker import Faker
from rest_framework import status
from rest_framework.test import APITestCase
from apps.user.models import Profile
from apps.user.services import UserService
from .factories import ProfileFactory, UserFactory
User = get_user_model()
@@ -136,6 +137,18 @@ class CurrentUserViewTest(APITestCase):
self.assertEqual(response.data["id"], self.user.id)
self.assertEqual(response.data["email"], self.user.email)
self.assertIn("profile", response.data)
self.assertEqual(response.data["role"], "user")
self.assertEqual(response.data["capabilities"]["can_access_admin_page"], False)
def test_get_current_user_returns_admin_role_for_staff_user(self):
self.user.is_staff = True
self.user.save(update_fields=["is_staff"])
response = self.client.get(self.current_user_url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.data["role"], "staff")
self.assertEqual(response.data["capabilities"]["can_access_admin_page"], True)
def test_get_current_user_unauthenticated(self):
"""Test getting current user when unauthenticated"""