diff options
| author | Max Nanis | 2026-02-24 17:26:15 -0500 |
|---|---|---|
| committer | Max Nanis | 2026-02-24 17:26:15 -0500 |
| commit | 8c1940445503fd6678d0961600f2be81622793a2 (patch) | |
| tree | b9173562b8824b5eaa805e446d9d780e1f23fb2a /tests/http/test_preview.py | |
| parent | 25d8c3c214baf10f6520cc1351f78473150e5d7a (diff) | |
| download | amt-jb-8c1940445503fd6678d0961600f2be81622793a2.tar.gz amt-jb-8c1940445503fd6678d0961600f2be81622793a2.zip | |
Extensive use of type checking. Movement of pytest conf towards handling managers (for db agnostic unittest). Starting to organize pytests.
Diffstat (limited to 'tests/http/test_preview.py')
| -rw-r--r-- | tests/http/test_preview.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/http/test_preview.py b/tests/http/test_preview.py new file mode 100644 index 0000000..2bdf265 --- /dev/null +++ b/tests/http/test_preview.py @@ -0,0 +1,41 @@ +# There are two types of "preview" - one is where we navigate direclty +# to it and one is where we redirect possibly + +import pytest +from httpx import AsyncClient + +from jb.models.hit import Hit + + +class TestPreview: + + @pytest.mark.anyio + async def test_preview_direct(self, httpxclient: AsyncClient): + client = httpxclient + 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 + + assert "James Billings loves you." in res.text + assert "https://cdn.jamesbillings67.com/james-has-style.css" in res.text + 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 + ): + client = httpxclient + + params = { + "workerId": None, + "assignmentId": amt_assignment_id, + "hitId": amt_hit_id, + } + res = await client.get("/work/", params=params) + + assert res.status_code == 302 + assert "/preview/" in res.headers["location"] |
