Skip to content

Commit

Permalink
style: apply AAA pattern with blank lines
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanttV committed Oct 17, 2024
1 parent 5d4c119 commit 7f13278
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions eox_core/api/v1/tests/integration/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1121,12 +1121,13 @@ def test_create_pre_enrollment_success(self, data: dict) -> None:

response = self.create_pre_enrollment(self.tenant_x, pre_enrollment_data)
response_data = response.json()
pre_enrollment_response = self.get_pre_enrollment(self.tenant_x, pre_enrollment_data)

self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertNotIn("warning", response_data)
self.assertEqual(response_data["email"], pre_enrollment_data["email"])
self.assertEqual(response_data["course_id"], pre_enrollment_data["course_id"])
self.assertEqual(response_data["auto_enroll"], pre_enrollment_data["auto_enroll"])
pre_enrollment_response = self.get_pre_enrollment(self.tenant_x, pre_enrollment_data)
self.assertEqual(pre_enrollment_response.status_code, status.HTTP_200_OK)

@ddt.data(
Expand Down Expand Up @@ -1156,11 +1157,11 @@ def test_create_pre_enrollment_missing_required_fields(self, errors: dict) -> No
}

response = self.create_pre_enrollment(self.tenant_x, incomplete_pre_enrollment_data)

response_data = response.json()
pre_enrollment_response = self.get_pre_enrollment(self.tenant_x, complete_pre_enrollment_data)

self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(response_data, errors)
pre_enrollment_response = self.get_pre_enrollment(self.tenant_x, complete_pre_enrollment_data)
self.assertEqual(pre_enrollment_response.status_code, status.HTTP_404_NOT_FOUND)

def test_create_pre_enrollmet_already_exists(self) -> None:
Expand All @@ -1186,6 +1187,7 @@ def test_create_pre_enrollmet_already_exists(self) -> None:

response = self.create_pre_enrollment(self.tenant_x, pre_enrollment_data)
response_data = response.json()

self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
self.assertEqual(
response_data["detail"],
Expand Down Expand Up @@ -1221,14 +1223,14 @@ def test_create_pre_enrollment_non_existent_course(self, data: dict) -> None:
}

response = self.create_pre_enrollment(self.tenant_x, pre_enrollment_data)

response_data = response.json()
pre_enrollment_response = self.get_pre_enrollment(self.tenant_x, pre_enrollment_data)

self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response_data["warning"], [f"Course with course_id:{course_id} does not exist"])
self.assertEqual(response_data["email"], pre_enrollment_data["email"])
self.assertEqual(response_data["course_id"], pre_enrollment_data["course_id"])
self.assertEqual(response_data["auto_enroll"], pre_enrollment_data["auto_enroll"])
pre_enrollment_response = self.get_pre_enrollment(self.tenant_x, pre_enrollment_data)
self.assertEqual(pre_enrollment_response.status_code, status.HTTP_200_OK)

@ddt.data(True, False)
Expand All @@ -1253,8 +1255,8 @@ def test_get_pre_enrollment_success(self, auto_enroll: bool) -> None:
self.create_pre_enrollment(self.tenant_x, pre_enrollment_data)

response = self.get_pre_enrollment(self.tenant_x, pre_enrollment_data)

response_data = response.json()

self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response_data["course_id"], pre_enrollment_data["course_id"])
self.assertEqual(response_data["email"], pre_enrollment_data["email"])
Expand All @@ -1279,8 +1281,8 @@ def test_get_pre_enrollment_does_not_exist(self) -> None:
}

response = self.get_pre_enrollment(self.tenant_x, pre_enrollment_data)

response_data = response.json()

self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
self.assertEqual(
response_data["detail"],
Expand All @@ -1307,8 +1309,8 @@ def test_get_pre_enrollment_course_with_not_valid_org(self) -> None:
}

response = self.get_pre_enrollment(self.tenant_x, pre_enrollment_data)

response_data = response.json()

self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(response_data["course_id"], [f"Invalid course_id {course_id}"])

Expand All @@ -1335,8 +1337,8 @@ def test_update_pre_enrollment_success(self) -> None:
pre_enrollment_data["auto_enroll"] = False

response = self.update_pre_enrollment(self.tenant_x, pre_enrollment_data)

response_data = response.json()

self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response_data["course_id"], pre_enrollment_data["course_id"])
self.assertEqual(response_data["email"], pre_enrollment_data["email"])
Expand All @@ -1361,14 +1363,14 @@ def test_update_pre_enrollment_does_not_exist(self) -> None:
}

response = self.update_pre_enrollment(self.tenant_x, pre_enrollment_data)

response_data = response.json()
pre_enrollment_response = self.get_pre_enrollment(self.tenant_x, pre_enrollment_data)

self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
self.assertEqual(
response_data["detail"],
f"Pre-enrollment not found for email: {self.user['email']} course_id: {self.demo_course_id}",
)
pre_enrollment_response = self.get_pre_enrollment(self.tenant_x, pre_enrollment_data)
self.assertEqual(pre_enrollment_response.status_code, status.HTTP_404_NOT_FOUND)

@ddt.data(
Expand Down Expand Up @@ -1399,11 +1401,11 @@ def test_update_pre_enrollment_missing_required_fields(self, errors: dict) -> No
}

response = self.update_pre_enrollment(self.tenant_x, incomplete_pre_enrollment_data)

response_data = response.json()
pre_enrollment_response = self.get_pre_enrollment(self.tenant_x, complete_pre_enrollment_data)

self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(response_data, errors)
pre_enrollment_response = self.get_pre_enrollment(self.tenant_x, complete_pre_enrollment_data)
self.assertEqual(pre_enrollment_response.status_code, status.HTTP_200_OK)

def test_delete_pre_enrollment_success(self) -> None:
Expand All @@ -1429,9 +1431,9 @@ def test_delete_pre_enrollment_success(self) -> None:
pre_enrollment_data["auto_enroll"] = False

response = self.delete_pre_enrollment(self.tenant_x, pre_enrollment_data)
pre_enrollment_response = self.get_pre_enrollment(self.tenant_x, pre_enrollment_data)

self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
pre_enrollment_response = self.get_pre_enrollment(self.tenant_x, pre_enrollment_data)
self.assertEqual(pre_enrollment_response.status_code, status.HTTP_404_NOT_FOUND)

def test_delete_pre_enrollment_does_not_exist(self) -> None:
Expand All @@ -1453,8 +1455,8 @@ def test_delete_pre_enrollment_does_not_exist(self) -> None:
}

response = self.delete_pre_enrollment(self.tenant_x, pre_enrollment_data)

response_data = response.json()

self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
self.assertEqual(
response_data["detail"],
Expand Down Expand Up @@ -1489,11 +1491,11 @@ def test_delete_pre_enrollment_missing_required_fields(self, errors: dict) -> No
}

response = self.delete_pre_enrollment(self.tenant_x, incomplete_pre_enrollment_data)

response_data = response.json()
pre_enrollment_response = self.get_pre_enrollment(self.tenant_x, complete_pre_enrollment_data)

self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(response_data, errors)
pre_enrollment_response = self.get_pre_enrollment(self.tenant_x, complete_pre_enrollment_data)
self.assertEqual(pre_enrollment_response.status_code, status.HTTP_200_OK)


Expand All @@ -1517,8 +1519,8 @@ def test_info_view_success(self) -> None:
- The response contains the version, name and git commit hash.
"""
response = make_request(self.default_site, "GET", url=self.url, with_auth=False)

response_data = response.json()

self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertIn("version", response_data)
self.assertIn("name", response_data)
Expand Down

0 comments on commit 7f13278

Please sign in to comment.