aboutsummaryrefslogtreecommitdiff
path: root/tests/managers
diff options
context:
space:
mode:
Diffstat (limited to 'tests/managers')
-rw-r--r--tests/managers/__init__.py0
-rw-r--r--tests/managers/test_amt.py132
-rw-r--r--tests/managers/test_hit.py50
3 files changed, 0 insertions, 182 deletions
diff --git a/tests/managers/__init__.py b/tests/managers/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tests/managers/__init__.py
+++ /dev/null
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
diff --git a/tests/managers/test_hit.py b/tests/managers/test_hit.py
deleted file mode 100644
index 7227e4d..0000000
--- a/tests/managers/test_hit.py
+++ /dev/null
@@ -1,50 +0,0 @@
-from jb.managers.hit import HitManager, HitTypeManager
-from jb.models.hit import Hit, HitQuestion, HitType
-
-
-class TestHitQuestionManager:
-
- def test_base(self, question_record: HitQuestion):
- assert isinstance(question_record, HitQuestion)
- assert isinstance(question_record.id, int)
-
-
-class TestHitTypeManager:
-
- def test_create(self, htm: HitTypeManager, hit_type_record: HitType):
-
- assert isinstance(hit_type_record.id, int)
- assert isinstance(hit_type_record.amt_hit_type_id, str)
-
- count1 = len(htm.filter_active())
- # assert count1 == 1
-
- hit_type_record.min_active = 0
- htm.set_min_active(hit_type=hit_type_record)
-
- count2 = len(htm.filter_active())
- assert count1 - 1 == count2
-
-
-class TestHitManager:
-
- # def test_create
-
- # def update_status
-
- # def update_hit
-
- # def get_from_amt_id
-
- # get_from_amt_id_if_exists
-
- def test_get_active_count(self, hm: HitManager, hit_record: Hit):
-
- count = hm.get_active_count(hit_type_id=999_999_999)
- assert isinstance(count, int)
- assert count == 0
-
- count = hm.get_active_count(hit_type_id=hit_record.hit_type_id)
- assert count == 1
-
- # filter_active_ids