mirror of
https://github.com/TurTaskProject/TurTaskWeb.git
synced 2025-12-18 13:34:08 +01:00
Add user creation signal test and Spectacular need Authentication
This commit is contained in:
parent
5c9319c5f1
commit
41cf2fb6d3
@ -3,7 +3,4 @@ from django.apps import AppConfig
|
||||
|
||||
class BoardsConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'boards'
|
||||
|
||||
def ready(self):
|
||||
import boards.signals
|
||||
name = 'boards'
|
||||
@ -88,6 +88,7 @@ SPECTACULAR_SETTINGS = {
|
||||
'DESCRIPTION': 'API documentation for TurTask',
|
||||
'VERSION': '1.0.0',
|
||||
'SERVE_INCLUDE_SCHEMA': False,
|
||||
'SERVE_PERMISSIONS': ['rest_framework.permissions.IsAuthenticated'],
|
||||
}
|
||||
|
||||
REST_USE_JWT = True
|
||||
|
||||
@ -88,6 +88,7 @@ SPECTACULAR_SETTINGS = {
|
||||
'DESCRIPTION': 'API documentation for TurTask',
|
||||
'VERSION': '1.0.0',
|
||||
'SERVE_INCLUDE_SCHEMA': False,
|
||||
'SERVE_PERMISSIONS': ['rest_framework.permissions.IsAuthenticated'],
|
||||
}
|
||||
|
||||
REST_USE_JWT = True
|
||||
|
||||
@ -1,3 +1,39 @@
|
||||
from django.test import TestCase
|
||||
from rest_framework.test import APITestCase
|
||||
from rest_framework import status
|
||||
from django.urls import reverse
|
||||
from users.models import CustomUser, UserStats
|
||||
from boards.models import Board, ListBoard
|
||||
from tasks.models import Todo
|
||||
|
||||
# Create your tests here.
|
||||
class SignalsTest(APITestCase):
|
||||
def setUp(self):
|
||||
response = self.client.post(reverse('create_user'), {'email': 'testusertestuser123@mail.com',
|
||||
'username': 'testusertestuser123',
|
||||
'password': '321testpassword123'})
|
||||
# force login If response is 201 OK
|
||||
if response.status_code == status.HTTP_201_CREATED:
|
||||
self.user = CustomUser.objects.get(username='testusertestuser123')
|
||||
self.client.force_login(self.user)
|
||||
|
||||
def test_create_user_with_stas_default_boards_and_lists(self):
|
||||
# Stats check
|
||||
self.assertTrue(UserStats.objects.filter(user=self.user).exists())
|
||||
|
||||
# check if user is created
|
||||
self.assertEqual(CustomUser.objects.count(), 1)
|
||||
user = CustomUser.objects.get(username='testusertestuser123')
|
||||
|
||||
# Check for default board
|
||||
self.assertEqual(Board.objects.filter(user=self.user).count(), 1)
|
||||
|
||||
# Check for default lists in board
|
||||
default_board = Board.objects.get(user=self.user)
|
||||
self.assertEqual(ListBoard.objects.filter(board=default_board).count(), 4)
|
||||
|
||||
def test_create_user_with_placeholder_tasks(self):
|
||||
default_board = Board.objects.get(user=self.user)
|
||||
|
||||
# Check if placeholder tasks are created for each ListBoard
|
||||
for list_board in ListBoard.objects.filter(board=default_board):
|
||||
placeholder_tasks_count = Todo.objects.filter(list_board=list_board).count()
|
||||
self.assertTrue(placeholder_tasks_count > 0)
|
||||
Loading…
Reference in New Issue
Block a user