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,33 @@
|
||||
from django.test import TestCase
|
||||
from django.contrib.auth.models import User
|
||||
from rest_framework.test import APITestCase
|
||||
from rest_framework import status
|
||||
from exercises.models import Exercise
|
||||
|
||||
|
||||
class ExerciseAPITest(APITestCase):
|
||||
def setUp(self):
|
||||
self.user = User.objects.create_user(username='testuser2', password='testpass123')
|
||||
self.client.force_authenticate(user=self.user)
|
||||
|
||||
def test_list_exercises(self):
|
||||
response = self.client.get('/api/v1/exercises/')
|
||||
self.assertIn(response.status_code, [status.HTTP_200_OK, status.HTTP_404_NOT_FOUND])
|
||||
|
||||
def test_create_exercise(self):
|
||||
data = {
|
||||
'name': 'Push-ups',
|
||||
'category': 'kraft',
|
||||
'exercise_type': 'reps',
|
||||
'default_value': '20'
|
||||
}
|
||||
response = self.client.post('/api/v1/exercises/', data)
|
||||
self.assertIn(response.status_code, [status.HTTP_201_CREATED, status.HTTP_404_NOT_FOUND, status.HTTP_405_METHOD_NOT_ALLOWED])
|
||||
|
||||
def test_filter_by_category(self):
|
||||
Exercise.objects.create(name='Squat', category='kraft', exercise_type='reps', default_value='10')
|
||||
Exercise.objects.create(name='Run', category='ausdauer', exercise_type='time', default_value='5')
|
||||
response = self.client.get('/api/v1/exercises/?category=kraft')
|
||||
if response.status_code == 200:
|
||||
self.assertEqual(len(response.data['results']), 1)
|
||||
self.assertEqual(response.data['results'][0]['name'], 'Squat')
|
||||
Reference in New Issue
Block a user