aboutsummaryrefslogtreecommitdiff
path: root/tests/managers/test_amt.py
diff options
context:
space:
mode:
authorstuppie2026-11-04 12:11:03 -0600
committerstuppie2026-11-04 12:11:03 -0600
commit671a7b1b02503cfa5c9aecd40c27a0c2729a285b (patch)
tree6cb1bd7c33e3e1d243ee5ae74decc57faaa5742d /tests/managers/test_amt.py
parente99ec6b7e38113a2237dc1ff402d8f4337c651d5 (diff)
downloadamt-jb-671a7b1b02503cfa5c9aecd40c27a0c2729a285b.tar.gz
amt-jb-671a7b1b02503cfa5c9aecd40c27a0c2729a285b.zip
strip out AMT
Diffstat (limited to 'tests/managers/test_amt.py')
-rw-r--r--tests/managers/test_amt.py132
1 files changed, 0 insertions, 132 deletions
diff --git a/tests/managers/test_amt.py b/tests/managers/test_amt.py
deleted file mode 100644
index 6a944a8..0000000
--- a/tests/managers/test_amt.py
+++ /dev/null
@@ -1,132 +0,0 @@
-from mypy_boto3_mturk import MTurkClient
-from mypy_boto3_mturk.type_defs import (
- GetAccountBalanceResponseTypeDef,
- ListHITsResponseTypeDef,
-)
-
-from jb.managers.amt import AMTManager
-from jb.managers.hit import HitManager, HitTypeManager
-from jb.models.hit import HitQuestion, HitType
-
-# from jb.decorators import HM
-# from jb.flow.tasks import refill_hits, check_stale_hits, check_expired_hits
-
-
-# def test_refill_hits(
-# set_hit_types_in_db_min_active_0,
-# hit_type_record, expire_all_hits, amt_manager
-# ):
-
-# assert HM.get_active_count(hit_type_in_db.id) == 0
-# assert hit_type_in_db.min_active > 0
-# refill_hits()
-# assert HM.get_active_count(hit_type_in_db.id) == hit_type_in_db.min_active
-
-# amt_hit_ids = HM.filter_active_ids(hit_type_id=hit_type_in_db.id)
-# amt_hit_id = list(amt_hit_ids)[0]
-# hit, _ = amt_manager.get_hit_if_exists(amt_hit_id=amt_hit_id)
-# assert hit
-
-
-# def test_check_stale_hits():
-# # todo: I'd have to create some purposely stale hits.
-# # just make sure it runs for now
-# check_stale_hits()
-
-
-# def test_check_expired_hits():
-# # todo: I'd have to create some purposely expired hits.
-# # just make sure it runs for now
-# check_expired_hits()
-
-
-class TestMTurkClient:
-
- def test_sandbox(self, amt_client: MTurkClient):
- assert amt_client is not None
- assert "mturk-requester-sandbox" in amt_client.meta.endpoint_url
-
- balance: GetAccountBalanceResponseTypeDef = amt_client.get_account_balance()
- assert balance["AvailableBalance"] == "10000.00"
-
- # def test_create_hit()
-
- # def test_delete_hit()
-
- # def test_get_assignment(self, amt_client: MTurkClient):
-
- # def test_get_hit
-
- def test_list_hits(self, amt_client: MTurkClient, amtm: AMTManager):
- res: ListHITsResponseTypeDef = amt_client.list_hits()
- assert isinstance(res, dict)
- assert isinstance(res.get("HITs"), list)
-
- for hit in res["HITs"]:
- assert isinstance(hit, dict)
-
- assert isinstance(hit.get("HITId"), str)
- assert isinstance(hit.get("HITTypeId"), str)
- assert isinstance(hit.get("HITGroupId"), str)
- assert isinstance(hit.get("Title"), str)
-
- # botocore.errorfactory.RequestError: An error occurred
- # (RequestError) when calling the DeleteHIT operation: This
- # HIT is currently in the state 'Assignable'. This operation
- # can be called with a status of: Reviewing, Reviewable
- # (1772146028380 s)
-
- if hit["HITStatus"] in ["Reviewing", "Reviewable"]:
- print(
- f"Deleting HIT with id {hit['HITId']} and status {hit['HITStatus']}"
- )
- amt_client.delete_hit(HITId=hit["HITId"])
-
- elif hit["HITStatus"] == "Assignable":
- # I don't know... just let expire I guess. To changes it's
- # status you need to do manage Assignments (I think)
-
- # amt_client.update_hit_review_status(HITId=hit["HITId"], Revert=True)
- pass
-
- amtm.expire_all_hits()
-
-
-class TestAMTManager:
-
- def test_create_hit_type(self, amtm: AMTManager, hit_type: HitType):
- assert hit_type.amt_hit_type_id is None
-
- amtm.create_hit_type(hit_type=hit_type)
- assert hit_type.amt_hit_type_id is not None
-
- def test_create_hit_with_hit_type(
- self,
- amtm: AMTManager,
- htm: HitTypeManager,
- hm: HitManager,
- hit_type_record_with_amt_id: HitType,
- question_record: HitQuestion,
- ):
-
- sandbox_amt_hit_type_id = hit_type_record_with_amt_id.amt_hit_type_id
- assert isinstance(sandbox_amt_hit_type_id, str)
-
- res = [
- x
- for x in htm.filter_active()
- if x.amt_hit_type_id == sandbox_amt_hit_type_id
- ]
-
- assert len(res) == 1
- sandbox_hit_type = res[0]
-
- hit = amtm.create_hit_with_hit_type(
- hit_type=sandbox_hit_type, question=question_record
- )
-
- assert hit.amt_hit_id is not None
- assert hit.id is None
-
- hm.create(hit)
- assert hit.id is not None