Skip to content

Commit

Permalink
initialize test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilOrv committed Apr 1, 2025
1 parent 0a5f51a commit dfec7ea
Showing 1 changed file with 86 additions and 3 deletions.
89 changes: 86 additions & 3 deletions backend/tests/TestExerciseNumber.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def setUp(self):
self.user = get_user_model().objects.create_user(username="testuser", password="password")
self.client.force_authenticate(self.user)

def test_create_workout_valid(self): #
def test_exercise_number_negative_number(self):
response = self.client.post("/api/workouts/", {
"name": "Morning Run",
"date": now().isoformat(),
Expand All @@ -27,7 +27,7 @@ def test_create_workout_valid(self): #
assert response.status_code == 201
assert Workout.objects.count() == 1

def test_create_workout_invalid_date(self): #
def test_exercise_number_non_number(self): #
response = self.client.post("/api/workouts/", {
"name": "Invalid Run",
"date": "invalid_date",
Expand All @@ -38,4 +38,87 @@ def test_create_workout_invalid_date(self): #
}, format="json")

assert response.status_code == 400 # Should return validation error


def test_exercise_number_min_minus(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

def test_exercise_number_min(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

def test_exercise_number_min_plus(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

def test_exercise_number_nom(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

def test_exercise_number_max_minus(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

def test_exercise_number_max(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

def test_exercise_number_max_plus(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

0 comments on commit dfec7ea

Please sign in to comment.