Skip to content

Commit

Permalink
Update test_special_value_workout.py
Browse files Browse the repository at this point in the history
  • Loading branch information
malenelu authored and GitHub Enterprise committed Apr 3, 2025
1 parent f08b0c2 commit 3c49d21
Showing 1 changed file with 40 additions and 28 deletions.
68 changes: 40 additions & 28 deletions backend/tests/test_special_value_workout.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,49 @@
"""
TC_005 - Special value test for the limit of sets in an exercise instance
TC_005 - Special value test for creating a valid and invalid workout
"""
from django.test import TestCase

import pytest
from django.test import TestCase #
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

def test_create_valid_workout(self):
response = self.client.post("/api/workouts/", {
"name": "Full body toning",
"date": now().isoformat(),
"notes": "Workout for women",
"visibility": "PU",
"owner": self.user.id,
"exercise_instances": []
}, format="json")

print(f"Response data: {response.data}")
print(f"Response status code: {response.status_code}")
@pytest.mark.django_db

assert response.status_code == 201
assert Workout.objects.count() == 1

def test_create_invalid_workout(self):
response = self.client.post("/api/workouts/", {
"name": "Full body toning",
"date": "today", # text instead of a date format
"notes": "Workout for women",
"visibility": "XO", # non-existent visibility
"owner": self.user.id,
"exercise_instances": []
class User(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_valid_workout(self):
response = self.client.post("/api/workouts/", {
"name": "Full body toning",
"date": now().isoformat(),
"notes": "Workout for women",
"visibility": "PU",
"owner": self.user.id,
"exercise_instances": []
}, format="json")

print(f"Error response data: {response.data}")
print(f"Error response status code: {response.status_code}")
print(f"Response data: {response.data}")
print(f"Response status code: {response.status_code}")

assert response.status_code == 400
assert response.status_code == 201
assert Workout.objects.count() == 1

def test_create_invalid_workout(self):
response = self.client.post("/api/workouts/", {
"name": "Full body toning",
"date": "today", # text instead of a date format
"notes": "Workout for women",
"visibility": "XO", # non-existent visibility
"owner": self.user.id,
"exercise_instances": []
}, format="json")

print(f"Error response data: {response.data}")
print(f"Error response status code: {response.status_code}")

assert response.status_code == 400

0 comments on commit 3c49d21

Please sign in to comment.