aboutsummaryrefslogtreecommitdiff
path: root/tests/fixtures/http.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/fixtures/http.py')
-rw-r--r--tests/fixtures/http.py50
1 files changed, 9 insertions, 41 deletions
diff --git a/tests/fixtures/http.py b/tests/fixtures/http.py
index e38c853..0f88fb8 100644
--- a/tests/fixtures/http.py
+++ b/tests/fixtures/http.py
@@ -1,7 +1,6 @@
-import json
import secrets
from collections.abc import AsyncGenerator
-from typing import Any
+from uuid import uuid4
import httpx
import pytest
@@ -10,12 +9,8 @@ from asgi_lifespan import LifespanManager
from generalresearch.redis_helper import RedisConfig
from httpx import ASGITransport, AsyncClient
-from jb.config import JB_EVENTS_STREAM, settings
from jb.decorators import get_redis_config
from jb.main import app
-from jb.models.assignment import AssignmentStub
-from jb.models.hit import Hit
-from tests import generate_amt_id
@pytest.fixture(scope="session")
@@ -64,43 +59,16 @@ def mock_requests():
yield m
-def generate_hex_id(length: int = 40) -> str:
- # length is number of hex chars, so we need length//2 bytes
- return secrets.token_hex(length // 2)
+@pytest.fixture
+def email() -> str:
+ return "unittest@generalresearch.com"
@pytest.fixture
-def mturk_event_body_record(
- hit_record: Hit, assignment_stub_record: AssignmentStub
-) -> dict[str, Any]:
- return {
- "Type": "Notification",
- "Message": json.dumps(
- {
- "Events": [
- {
- "EventType": "AssignmentSubmitted",
- "EventTimestamp": "2025-10-16T18:45:51.000000Z",
- "HITId": hit_record.amt_hit_id,
- "AssignmentId": assignment_stub_record.amt_assignment_id,
- "HITTypeId": hit_record.amt_hit_type_id,
- }
- ],
- "EventDocId": generate_hex_id(),
- "SourceAccount": settings.aws_owner_id,
- "CustomerId": generate_amt_id(length=14),
- "EventDocVersion": "2006-05-05",
- }
- ),
- }
+def amt_worker_id() -> str:
+ return uuid4().hex
-@pytest.fixture()
-def clean_mturk_events_redis_stream(redis_config: RedisConfig):
- redis_client = redis_config.create_redis_client()
-
- redis_client.xtrim(JB_EVENTS_STREAM, maxlen=0)
- assert redis_client.xlen(JB_EVENTS_STREAM) == 0
- yield
- redis_client.xtrim(JB_EVENTS_STREAM, maxlen=0)
- assert redis_client.xlen(JB_EVENTS_STREAM) == 0
+def generate_hex_id(length: int = 40) -> str:
+ # length is number of hex chars, so we need length//2 bytes
+ return secrets.token_hex(length // 2)