diff options
| author | Max Nanis | 2026-02-27 02:35:47 -0500 |
|---|---|---|
| committer | Max Nanis | 2026-02-27 02:35:47 -0500 |
| commit | 205449a8e59c78f3b1032a3b996463d22588f05f (patch) | |
| tree | fdb706dc4ed6ab5e173d0ad4d39fcdd198a91ab8 /tests | |
| parent | dadd9643feceac94a2b84d9a3d3dda667f17583d (diff) | |
| download | amt-jb-205449a8e59c78f3b1032a3b996463d22588f05f.tar.gz amt-jb-205449a8e59c78f3b1032a3b996463d22588f05f.zip | |
tests.flow all pass. Now everything is GREEN ✅
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/fixtures/flow.py | 25 | ||||
| -rw-r--r-- | tests/fixtures/models.py | 4 | ||||
| -rw-r--r-- | tests/flow/__init__.py | 16 | ||||
| -rw-r--r-- | tests/flow/test_tasks.py | 17 |
4 files changed, 48 insertions, 14 deletions
diff --git a/tests/fixtures/flow.py b/tests/fixtures/flow.py index 5ee2026..dd2f83e 100644 --- a/tests/fixtures/flow.py +++ b/tests/fixtures/flow.py @@ -27,10 +27,10 @@ from generalresearchutils.models.thl.definitions import PayoutStatus @pytest.fixture def approved_assignment_stubs( assignment_response: GetAssignmentResponseTypeDef, - assignment_response_approved: Callable[[str], GetAssignmentResponseTypeDef], + assignment_response_factory_approved: Callable[[str], GetAssignmentResponseTypeDef], amt_assignment_id: str, amt_hit_id: str, - get_hit_response_reviewing: GetHITResponseTypeDef, + hit_response_reviewing: GetHITResponseTypeDef, ) -> Callable[..., list[Dict[str, Any]]]: # These are the AMT_CLIENT stubs/mocks that need to be set when running @@ -43,8 +43,8 @@ def approved_assignment_stubs( ) -> list[Dict[str, Any]]: response = override_response or assignment_response - approve_response = override_approve_response or assignment_response_approved( - feedback + approve_response = ( + override_approve_response or assignment_response_factory_approved(feedback) ) return [ @@ -74,7 +74,7 @@ def approved_assignment_stubs( }, { "operation": "get_hit", - "response": get_hit_response_reviewing, + "response": hit_response_reviewing, "expected_params": {"HITId": amt_hit_id}, }, ] @@ -218,7 +218,15 @@ def mock_thl_responses( class MockThlProfileResponse: def json(self): - return {"user_profile": {"user": {"blocked": user_blocked}}} + return { + "user_profile": { + "user": { + "product_id": settings.product_id, + "product_user_id": amt_worker_id, + "blocked": user_blocked, + } + } + } return MockThlProfileResponse() @@ -227,7 +235,10 @@ def mock_thl_responses( class MockThlWalletResponse: def json(self) -> Dict[str, Any]: return { - "wallet": {"redeemable_amount": wallet_redeemable_amount} + "wallet": { + "amount": wallet_redeemable_amount, + "redeemable_amount": wallet_redeemable_amount, + } } return MockThlWalletResponse() diff --git a/tests/fixtures/models.py b/tests/fixtures/models.py index 03bd8a2..bdb4e12 100644 --- a/tests/fixtures/models.py +++ b/tests/fixtures/models.py @@ -242,7 +242,7 @@ def assignment_record( @pytest.fixture -def assignment_factory(hit: Hit) -> Callable[[Optional[str]], Assignment]: +def assignment_factory(hit_record: Hit) -> Callable[[Optional[str]], Assignment]: def _inner(amt_worker_id: Optional[str] = None) -> Assignment: now = datetime.now(tz=timezone.utc) @@ -251,7 +251,7 @@ def assignment_factory(hit: Hit) -> Callable[[Optional[str]], Assignment]: return Assignment( amt_assignment_id=amt_assignment_id, - amt_hit_id=hit.amt_hit_id, + amt_hit_id=hit_record.amt_hit_id, amt_worker_id=amt_worker_id, status=AssignmentStatus.Submitted, modified_at=now, diff --git a/tests/flow/__init__.py b/tests/flow/__init__.py index e69de29..3c88c7e 100644 --- a/tests/flow/__init__.py +++ b/tests/flow/__init__.py @@ -0,0 +1,16 @@ +# def test_a_hit(): +# hit_type = HitType( +# title="Sandbox Test 2026-02-04", +# description="test description", +# reward=USDCent(5), +# keywords="a,b,c", +# min_active=10, +# ) +# AMTManager.create_hit_type(hit_type=hit_type) +# HTM.create(hit_type) + +# hit_type = HTM.get(amt_hit_type_id=hit_type.amt_hit_type_id) +# hit = create_hit_from_hittype(hit_type) + +# hit_type = HTM.get(amt_hit_type_id="3QMCR5SRRVWV0O3UDSC64VSB8KL4GL") +# hit = create_hit_from_hittype(hit_type) diff --git a/tests/flow/test_tasks.py b/tests/flow/test_tasks.py index 2aeffb9..3a71504 100644 --- a/tests/flow/test_tasks.py +++ b/tests/flow/test_tasks.py @@ -227,8 +227,8 @@ class TestProcessAssignmentSubmitted: ..., GetAssignmentResponseTypeDef ], assignment_response_no_tsid: GetAssignmentResponseTypeDef, - assignment_factory: Callable[..., Assignment], - hit_record: Hit, + assignment_record_factory: Callable[..., Assignment], + hit_record: Hit, # used in assignment_factory amt_worker_id: str, ): # An assignment is submitted. The hit and assignment stub exist in the DB. @@ -237,9 +237,16 @@ class TestProcessAssignmentSubmitted: # Going to create and submit 3 assignments w no work # (all on the same hit, which we don't do in JB for real, # but doesn't matter here) - _a1 = assignment_factory(hit_id=hit_record.id, amt_worker_id=amt_worker_id) - _a2 = assignment_factory(hit_id=hit_record.id, amt_worker_id=amt_worker_id) - _a3 = assignment_factory(hit_id=hit_record.id, amt_worker_id=amt_worker_id) + _a1 = assignment_record_factory( + hit_id=hit_record.id, amt_worker_id=amt_worker_id + ) + _a2 = assignment_record_factory( + hit_id=hit_record.id, amt_worker_id=amt_worker_id + ) + _a3 = assignment_record_factory( + hit_id=hit_record.id, amt_worker_id=amt_worker_id + ) + assert am.missing_tsid_count(amt_worker_id=amt_worker_id) == 3 # So now, we'll reject, b/c they've already gotten 3 warnings |
