diff options
Diffstat (limited to 'tests/http/test_preview.py')
| -rw-r--r-- | tests/http/test_preview.py | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/tests/http/test_preview.py b/tests/http/test_preview.py index 2bdf265..467c63c 100644 --- a/tests/http/test_preview.py +++ b/tests/http/test_preview.py @@ -3,8 +3,8 @@ import pytest from httpx import AsyncClient - from jb.models.hit import Hit +from jb.models.assignment import AssignmentStub class TestPreview: @@ -15,8 +15,6 @@ class TestPreview: res = await client.get("/preview/") assert res.status_code == 200 - # the response is an html page - assert res.headers["content-type"] == "text/html; charset=utf-8" assert res.num_bytes_downloaded == 507 @@ -25,11 +23,17 @@ class TestPreview: assert "https://cdn.jamesbillings67.com/james-billings.js" in res.text @pytest.mark.anyio - async def test_preview_redirect_from_work( - self, httpxclient: AsyncClient, amt_hit_id, amt_assignment_id + async def test_preview_redirect_from_work_random_str( + self, httpxclient: AsyncClient, amt_hit_id: str, amt_assignment_id: str ): client = httpxclient + """ + The redirect occurs regardless of any parameter validation. This is + because the query params will be used for record lookup on the work + page itself. + """ + params = { "workerId": None, "assignmentId": amt_assignment_id, @@ -39,3 +43,28 @@ class TestPreview: assert res.status_code == 302 assert "/preview/" in res.headers["location"] + + @pytest.mark.anyio + async def test_preview_redirect_from_work_records( + self, + httpxclient: AsyncClient, + hit_record: Hit, + assignment_stub_record: AssignmentStub, + ): + client = httpxclient + + """ + The redirect occurs regardless of any parameter validation. This is + because the query params will be used for record lookup on the work + page itself. + """ + + params = { + "workerId": None, + "assignmentId": assignment_stub_record.amt_assignment_id, + "hitId": hit_record.amt_hit_id, + } + res = await client.get("/work/", params=params) + + assert res.status_code == 302 + assert "/preview/" in res.headers["location"] |
