aboutsummaryrefslogtreecommitdiff
path: root/tests/http/test_statuses.py
diff options
context:
space:
mode:
authorMax Nanis2026-02-24 17:26:15 -0500
committerMax Nanis2026-02-24 17:26:15 -0500
commit8c1940445503fd6678d0961600f2be81622793a2 (patch)
treeb9173562b8824b5eaa805e446d9d780e1f23fb2a /tests/http/test_statuses.py
parent25d8c3c214baf10f6520cc1351f78473150e5d7a (diff)
downloadamt-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_statuses.py')
-rw-r--r--tests/http/test_statuses.py102
1 files changed, 0 insertions, 102 deletions
diff --git a/tests/http/test_statuses.py b/tests/http/test_statuses.py
deleted file mode 100644
index ffc98fd..0000000
--- a/tests/http/test_statuses.py
+++ /dev/null
@@ -1,102 +0,0 @@
-from datetime import datetime, timezone, timedelta
-from urllib.parse import urlencode
-
-import pytest
-from uuid import uuid4
-from httpx import AsyncClient
-
-from jb.config import settings
-
-
-@pytest.mark.anyio
-async def test_get_statuses(httpxclient: AsyncClient, no_limit, amt_worker_id):
- # Expects settings.fsb_host to point to a functional thl-fsb
- client = httpxclient
- now = datetime.now(tz=timezone.utc)
-
- params = {"worker_id": amt_worker_id}
- res = await client.get(f"/statuses/", params=params)
- assert res.status_code == 200
- assert res.json() == []
-
- params = {"worker_id": amt_worker_id, "started_after": now.isoformat()}
- res = await client.get(f"/statuses/", params=params)
- assert res.status_code == 422
- assert "Input should be a valid integer" in res.text
-
-
-@pytest.fixture
-def fsb_get_statuses_example_response(amt_worker_id, tsid1, tsid2):
- return {
- "tasks_status": [
- {
- "tsid": tsid1,
- "product_id": settings.product_id,
- "bpuid": amt_worker_id,
- "started": "2025-06-12T03:27:24.902280Z",
- "finished": "2025-06-12T03:29:37.626481Z",
- "status": 2,
- "payout": 0,
- "user_payout": None,
- "payout_format": None,
- "user_payout_string": None,
- "kwargs": {},
- "status_code_1": "SESSION_START_QUALITY_FAIL",
- "status_code_2": "ENTRY_URL_MODIFICATION",
- },
- {
- "tsid": tsid2,
- "product_id": settings.product_id,
- "bpuid": amt_worker_id,
- "started": "2025-06-12T03:30:18.176826Z",
- "finished": "2025-06-12T03:36:58.789059Z",
- "status": 2,
- "payout": 0,
- "user_payout": None,
- "payout_format": None,
- "user_payout_string": None,
- "kwargs": {},
- "status_code_1": "BUYER_QUALITY_FAIL",
- "status_code_2": None,
- },
- ]
- }
-
-
-@pytest.mark.anyio
-async def test_get_statuses_mock(
- httpxclient: AsyncClient,
- no_limit,
- amt_worker_id,
- mock_requests,
- fsb_get_statuses_example_response,
- tsid1,
- tsid2,
-):
- client = httpxclient
- now = datetime.now(tz=timezone.utc)
- started_after = now - timedelta(minutes=5)
-
- # The fsb call we are mocking ------v
- params = {
- "bpuid": amt_worker_id,
- "started_after": round(started_after.timestamp()),
- "started_before": round(now.timestamp()),
- }
- url = f"{settings.fsb_host}{settings.product_id}/status/" + "?" + urlencode(params)
- mock_requests.get(url, json=fsb_get_statuses_example_response, status_code=200)
- # ---- end mock
-
- params = {
- "worker_id": amt_worker_id,
- "started_after": round(started_after.timestamp()),
- "started_before": round(now.timestamp()),
- }
- result = await client.get(f"/statuses/", params=params)
- assert result.status_code == 200
- res = result.json()
- assert len(res) == 2
- assert res == [
- {"status": 2, "tsid": tsid1},
- {"status": 2, "tsid": tsid2},
- ]