forked from mathialm/secfit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
EmilOrv
committed
Apr 1, 2025
1 parent
a561f63
commit 3f94011
Showing
3 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import pytest | ||
| from rest_framework.test import APIClient | ||
| from django.utils.timezone import now | ||
| from workouts.models import Workout | ||
| from django.contrib.auth import get_user_model | ||
|
|
||
| from django.test import TestCase | ||
|
|
||
| @pytest.mark.django_db | ||
| class TestExerciseNumber(TestCase): | ||
| def setUp(self): | ||
| self.client = APIClient() | ||
| self.user = get_user_model().objects.create_user(username="testuser", password="password") | ||
| self.client.force_authenticate(self.user) | ||
|
|
||
| def test_create_workout_valid(self): # | ||
| response = self.client.post("/api/workouts/", { | ||
| "name": "Morning Run", | ||
| "date": now().isoformat(), | ||
| "notes": "5km run", | ||
| "visibility": "PU", # Adding visibility field which is required | ||
| "owner": self.user.id, # Adding owner field which seems to be required | ||
| "exercise_instances": [] # Adding exercise_instances field which is required | ||
| }, format="json") | ||
|
|
||
|
|
||
| assert response.status_code == 201 | ||
| assert Workout.objects.count() == 1 | ||
|
|
||
| def test_create_workout_invalid_date(self): # | ||
| response = self.client.post("/api/workouts/", { | ||
| "name": "Invalid Run", | ||
| "date": "invalid_date", | ||
| "notes": "Wrong format", | ||
| "visibility": "PU", # Adding required field | ||
| "owner": self.user.id, # Adding required field | ||
| "exercise_instances": [] # Adding required field | ||
| }, format="json") | ||
|
|
||
| assert response.status_code == 400 # Should return validation error | ||
|
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import pytest | ||
| from rest_framework.test import APIClient | ||
| from django.utils.timezone import now | ||
| from workouts.models import Workout | ||
| from django.contrib.auth import get_user_model | ||
|
|
||
| from django.test import TestCase | ||
|
|
||
| @pytest.mark.django_db | ||
| class TestExerciseSet(TestCase): | ||
| def setUp(self): | ||
| self.client = APIClient() | ||
| self.user = get_user_model().objects.create_user(username="testuser", password="password") | ||
| self.client.force_authenticate(self.user) | ||
|
|
||
| def test_create_workout_valid(self): # | ||
| response = self.client.post("/api/workouts/", { | ||
| "name": "Morning Run", | ||
| "date": now().isoformat(), | ||
| "notes": "5km run", | ||
| "visibility": "PU", # Adding visibility field which is required | ||
| "owner": self.user.id, # Adding owner field which seems to be required | ||
| "exercise_instances": [] # Adding exercise_instances field which is required | ||
| }, format="json") | ||
|
|
||
|
|
||
| assert response.status_code == 201 | ||
| assert Workout.objects.count() == 1 | ||
|
|
||
| def test_create_workout_invalid_date(self): # | ||
| response = self.client.post("/api/workouts/", { | ||
| "name": "Invalid Run", | ||
| "date": "invalid_date", | ||
| "notes": "Wrong format", | ||
| "visibility": "PU", # Adding required field | ||
| "owner": self.user.id, # Adding required field | ||
| "exercise_instances": [] # Adding required field | ||
| }, format="json") | ||
|
|
||
| assert response.status_code == 400 # Should return validation error | ||
|
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters