Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
EwoutV committed Apr 16, 2024
1 parent 927bcb0 commit 86bb212
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 30 deletions.
6 changes: 1 addition & 5 deletions backend/api/tests/test_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,11 @@ def test_group_project(self):
# Parse the JSON content from the response
content_json = json.loads(response.content.decode("utf-8"))

expected_course_url = settings.TESTING_BASE_LINK + reverse(
"course-detail", args=[str(course.id)]
)

self.assertEqual(content_json["name"], project.name)
self.assertEqual(content_json["description"], project.description)
self.assertEqual(content_json["visible"], project.visible)
self.assertEqual(content_json["archived"], project.archived)
self.assertEqual(content_json["course"], expected_course_url)
self.assertEqual(content_json["course"]["id"], course.id)

def test_group_students(self):
"""Able to retrieve students details of a group."""
Expand Down
30 changes: 5 additions & 25 deletions backend/api/tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,15 +279,11 @@ def test_project_exists(self):

retrieved_project = content_json

expected_course_url = settings.TESTING_BASE_LINK + reverse(
"course-detail", args=[str(course.id)]
)

self.assertEqual(retrieved_project["name"], project.name)
self.assertEqual(retrieved_project["description"], project.description)
self.assertEqual(retrieved_project["visible"], project.visible)
self.assertEqual(retrieved_project["archived"], project.archived)
self.assertEqual(retrieved_project["course"], expected_course_url)
self.assertEqual(content_json["course"]["id"], course.id)

def test_project_course(self):
"""
Expand Down Expand Up @@ -319,21 +315,9 @@ def test_project_course(self):
self.assertEqual(retrieved_project["description"], project.description)
self.assertEqual(retrieved_project["visible"], project.visible)
self.assertEqual(retrieved_project["archived"], project.archived)

response = self.client.get(retrieved_project["course"], follow=True)

# Check if the response was successful
self.assertEqual(response.status_code, 200)

# Assert that the response is JSON
self.assertEqual(response.accepted_media_type, "application/json")

# Parse the JSON content from the response
content_json = json.loads(response.content.decode("utf-8"))

self.assertEqual(content_json["name"], course.name)
self.assertEqual(content_json["academic_startyear"], course.academic_startyear)
self.assertEqual(content_json["description"], course.description)
self.assertEqual(content_json["course"]["name"], course.name)
self.assertEqual(content_json["course"]["academic_startyear"], course.academic_startyear)
self.assertEqual(content_json["course"]["description"], course.description)

def test_project_structure_checks(self):
"""
Expand Down Expand Up @@ -371,15 +355,11 @@ def test_project_structure_checks(self):

retrieved_project = content_json

expected_course_url = settings.TESTING_BASE_LINK + reverse(
"course-detail", args=[str(course.id)]
)

self.assertEqual(retrieved_project["name"], project.name)
self.assertEqual(retrieved_project["description"], project.description)
self.assertEqual(retrieved_project["visible"], project.visible)
self.assertEqual(retrieved_project["archived"], project.archived)
self.assertEqual(retrieved_project["course"], expected_course_url)
self.assertEqual(content_json["course"]["id"], course.id)

response = self.client.get(retrieved_project["structure_checks"], follow=True)

Expand Down

0 comments on commit 86bb212

Please sign in to comment.