Skip to content

Commit

Permalink
test: add tests for mktg_redirect feature
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanttV committed Nov 13, 2024
1 parent 55cddc1 commit ab56e37
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
38 changes: 38 additions & 0 deletions eox_core/tests/integration/test_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,41 @@ def test_redirect_loggedout(self, with_session: bool) -> None:
self.assertEqual(response.url, f"{self.tenant_x_url}/{final_path}")
if not with_session:
self.assertEqual(response.history[0].status_code, status.HTTP_302_FOUND)

@ddt.data(False, True)
def test_mktg_redirect_with_empty_string(self, with_session: bool) -> None:
"""
Test the `mktg_redirect` feature with an empty string.
Open edX definitions tested:
- `configuration_helper.has_override_value`
- `configuration_helper.get_value`
Expected result:
- The status code is 200.
- The URL is the same as the requested URL.
"""
response = self.get_request(f"{self.tenant_x_url}/about", with_session)

self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.url, f"{self.tenant_x_url}/about")

@ddt.data(False, True)
def test_mktg_redirect_with_other_url(self, with_session: bool) -> None:
"""
Test the `mktg_redirect` feature with a different URL.
Open edX definitions tested:
- `configuration_helper.has_override_value`
- `configuration_helper.get_value`
Expected result:
- The history contains a 302 status code.
- The status code is 200.
- The URL is the configured redirect URL.
"""
response = self.get_request(f"{self.tenant_x_url}/dashboard", with_session)

self.assertEqual(response.history[0].status_code, status.HTTP_302_FOUND)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.url, "https://www.example.com/")
4 changes: 4 additions & 0 deletions fixtures/initial_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@
"fields": {
"external_key": "tenant-x-key",
"lms_configs": {
"MKTG_REDIRECTS": {
"about.html": "",
"dashboard.html": "https://www.example.com/"
},
"EDNX_CUSTOM_PATH_REDIRECTS": {
"/blog": {
"redirect_always": "/donate"
Expand Down

0 comments on commit ab56e37

Please sign in to comment.