aboutsummaryrefslogtreecommitdiff
path: root/tests/http/test_preview.py
diff options
context:
space:
mode:
authorMax Nanis2026-02-25 16:20:18 -0500
committerMax Nanis2026-02-25 16:20:18 -0500
commit04aee0dc7e908ce020d2d2c3f8ffb4a96424b883 (patch)
treeefb99622da9a962a73921a945373c019f98e6273 /tests/http/test_preview.py
parent8c1940445503fd6678d0961600f2be81622793a2 (diff)
downloadamt-jb-04aee0dc7e908ce020d2d2c3f8ffb4a96424b883.tar.gz
amt-jb-04aee0dc7e908ce020d2d2c3f8ffb4a96424b883.zip
test_notification (for sns mgmt), along with more type hinting on pytest conftest
Diffstat (limited to 'tests/http/test_preview.py')
-rw-r--r--tests/http/test_preview.py39
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"]