Skip to content

Commit

Permalink
Forgot to add the test_ at the front
Browse files Browse the repository at this point in the history
  • Loading branch information
CodingGirlGargi committed Apr 3, 2025
1 parent 8700f98 commit d798f63
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 29 deletions.
1 change: 1 addition & 0 deletions backend/media/users/2/file_a_Ap1XeTp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions backend/media/users/2/file_a_fWCr2qB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions backend/media/users/2/file_a_pIyi28o.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions backend/media/users/2/file_a_s9Ytvxg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 8 additions & 10 deletions backend/tests/test_TC001.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def setUp(self):
name="Valid Exercise", description="A valid exercise", unit="reps"
)

def test_valid_workout_creation(self):
def test_inside_boundary(self):
"""Test creating a workout with valid exercises."""
url = reverse('workout-list')
valid_workout_data = {
Expand All @@ -37,12 +37,12 @@ def test_valid_workout_creation(self):
}

response = self.client.post(url, valid_workout_data, format='json')
#print(response.content) # For debugging purposes
print(response.content) # For debugging purposes

# Assert that the workout was created successfully
self.assertEqual(response.status_code, status.HTTP_201_CREATED)

def test_invalid_workout_creation_future_date(self):
def test_outside_boundary_right_hand(self):
"""Test creating a workout with an invalid future date."""
url = reverse('workout-list')
invalid_workout_data = {
Expand All @@ -60,12 +60,12 @@ def test_invalid_workout_creation_future_date(self):
}

response = self.client.post(url, invalid_workout_data, format='json')
#print(response.content) # For debugging purposes
print(response.content) # For debugging purposes

# Assert that the workout creation fails due to invalid date
#self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

def test_invalid_workout_creation_past_date(self):
def test_outside_boundary_left_hand(self):
"""Test creating a workout with an invalid future date."""
url = reverse('workout-list')
invalid_workout_data = {
Expand All @@ -83,10 +83,8 @@ def test_invalid_workout_creation_past_date(self):
}




response = self.client.post(url, invalid_workout_data, format='json')
#print(response.content) # For debugging purposes
print(response.content) # For debugging purposes

# Assert that the workout creation fails due to invalid date
#self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
11 changes: 8 additions & 3 deletions backend/tests/test_TC002.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ def test_athlete_initially_has_no_coach(self):
self.assertIsNone(self.athlete.coach)

def test_athlete_sends_request_to_coach_and_coach_accepts(self):
"""Athlete sends request to a coach, and the coach accepts."""

"""Athlete sends request to a coach, and the coach accepts."""
# Athlete sends request to coach1
response = self.client.post(
"/api/offers/",
Expand Down Expand Up @@ -52,6 +51,8 @@ def test_athlete_sends_request_to_coach_and_coach_accepts(self):
self.athlete.refresh_from_db()
self.assertEqual(self.athlete.coach, self.coach1)

print("Class1 has run successfully!")

def test_athlete_sends_requests_to_multiple_coaches_and_last_accepting_coach_is_assigned(self):
"""Athlete sends requests to multiple coaches; the last accepting coach should be assigned."""

Expand Down Expand Up @@ -94,6 +95,8 @@ def test_athlete_sends_requests_to_multiple_coaches_and_last_accepting_coach_is_
self.athlete.refresh_from_db()
self.assertEqual(self.athlete.coach, self.coach2)

print("Class 2 has run successfully! ")

def test_multiple_requests_to_single_coach_all_other_requests_get_deleted_on_acceptance(self):
"""Athlete sends multiple requests to a single coach, only one gets accepted, others should be removed."""

Expand Down Expand Up @@ -126,4 +129,6 @@ def test_multiple_requests_to_single_coach_all_other_requests_get_deleted_on_acc

# Verify that all other pending offers from athlete to coach1 were deleted
remaining_offers = Offer.objects.filter(owner=self.athlete, recipient=self.coach1)
self.assertEqual(len(remaining_offers), 1) # Only one accepted offer should remain
self.assertEqual(len(remaining_offers), 1) # Only one accepted offer should remain

print("Class 3 has run successfully! ")
107 changes: 91 additions & 16 deletions backend/tests/test_TC003.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,50 +19,125 @@ def setUp(self):
name="Valid Exercise", description="A valid exercise", unit="reps"
)

def test_valid_workout_creation(self):
"""Test creating a workout with valid exercises."""
def test_inside_boundary(self):
url = reverse('workout-list')
valid_workout_data = {
"name": "Valid Workout",
inside_boundary_data = {
"name": "Inside Boundary",
"date": "2025-04-01T10:00:00Z",
"notes": "This is a valid workout",
"visibility": "PU",
"exercise_instances": [
{
"exercise": f"/api/exercises/{self.valid_exercise.id}/",
"sets": 3,
"number": 10
"sets": 1,
"number": 1
}
]
}

response = self.client.post(url, valid_workout_data, format='json')
response = self.client.post(url, inside_boundary_data, format='json')
print(response.content) # For debugging purposes

# Assert that the workout was created successfully
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
print("/n The Workout with values-inside boundary- is created!")

def test_invalid_workout_creation(self):
"""Test creating a workout with invalid exercises ie using boundary values."""
def test_on_boundary(self):
url = reverse('workout-list')
invalid_workout_data = {
"name": "Invalid Workout",
on_boundary_data = {
"name": "On Boundary Workout",
"date": "2025-04-01T10:00:00Z",
"notes": "This workout has boundary values for the exercises",
"notes": "This workout has on boundary values for the exercises",
"visibility": "PU",
"exercise_instances": [
{
"exercise": f"/api/exercises/{self.valid_exercise.id}/",
"sets": -3, # Invalid: negative sets
"number": -10 # Invalid: negative number
"sets": 0,
"number": 0
}
]
}

response = self.client.post(url, invalid_workout_data, format='json')
response = self.client.post(url, on_boundary_data, format='json')
print(response.content) # For debugging purposes

# Assert that the workout creation fails due to invalid exercise instances
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
#self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)


print("The workout with values- on boundary- is created!")

def test_outside_boundary(self):
url = reverse('workout-list')
outside_boundary_data = {
"name": "Outside Boundary",
"date": "2025-04-01T10:00:00Z",
"notes": "This workout has outside boundary values for the exercises",
"visibility": "PU",
"exercise_instances": [
{
"exercise": f"/api/exercises/{self.valid_exercise.id}/",
"sets": -1, # Invalid: negative sets
"number": -1 # Invalid: negative number
}
]
}

response = self.client.post(url, outside_boundary_data, format='json')
print(response.content) # For debugging purposes

# Assert that the workout creation fails due to invalid exercise instances
#self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

print("The workout with values- outside boundary- is created!")

def test_robust_outside_boundary(self):
url = reverse('workout-list')
robust_outside_boundary_data = {
"name": "Robust Outside Boundary Workout",
"date": "2025-04-01T10:00:00Z",
"notes": "This workout has outside boundary values for the exercises",
"visibility": "PU",
"exercise_instances": [
{
"exercise": f"/api/exercises/{self.valid_exercise.id}/",
"sets": -1000, # Invalid: negative sets
"number": -10000 # Invalid: negative number
}
]
}

response = self.client.post(url, robust_outside_boundary_data, format='json')
print(response.content) # For debugging purposes

# Assert that the workout creation fails due to invalid exercise instances
#self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

print("The workout with values- robust outside boundary- is created!")

def test_robust_inside_boundary(self):
url = reverse('workout-list')
robust_inside_boundary_data = {
"name": "Robust Inside Boundary Workout",
"date": "2025-04-01T10:00:00Z",
"notes": "This workout has robust inside boundary values for the exercises",
"visibility": "PU",
"exercise_instances": [
{
"exercise": f"/api/exercises/{self.valid_exercise.id}/",
"sets": 1000,
"number": 10000
}
]
}

response = self.client.post(url, robust_inside_boundary_data, format='json')
print(response.content) # For debugging purposes

# Assert that the workout creation fails due to invalid exercise instances
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
#self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

print("The workout with values- robust inside boundary- is created!")

0 comments on commit d798f63

Please sign in to comment.