Initial commit: WrestleDesk full project
- Django backend with DRF (clubs, wrestlers, trainers, exercises, templates, trainings, homework, locations, leistungstest) - Next.js 16 frontend with React, Shadcn UI, Tailwind - JWT authentication - Full CRUD for all entities - Calendar view for trainings - Homework management system - Leistungstest tracking
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
from django.test import TestCase
|
||||
from django.contrib.auth.models import User
|
||||
from rest_framework.test import APITestCase
|
||||
from rest_framework import status
|
||||
from clubs.models import Club
|
||||
from auth_app.models import UserProfile
|
||||
|
||||
|
||||
class ClubAPITest(APITestCase):
|
||||
def setUp(self):
|
||||
self.user = User.objects.create_user(username='testuser', password='testpass123')
|
||||
self.club = Club.objects.create(name='Test Club')
|
||||
UserProfile.objects.create(user=self.user, club=self.club)
|
||||
self.client.force_authenticate(user=self.user)
|
||||
|
||||
def test_list_clubs(self):
|
||||
response = self.client.get('/api/v1/clubs/')
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
def test_create_club(self):
|
||||
initial_count = Club.objects.count()
|
||||
data = {'name': 'Test Club API', 'short_name': 'TC'}
|
||||
response = self.client.post('/api/v1/clubs/', data)
|
||||
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
||||
self.assertEqual(Club.objects.count(), initial_count + 1)
|
||||
self.assertEqual(Club.objects.last().name, 'Test Club API')
|
||||
|
||||
def test_club_str(self):
|
||||
club = Club.objects.create(name="API Test Club")
|
||||
self.assertEqual(str(club), "API Test Club")
|
||||
Reference in New Issue
Block a user