aboutsummaryrefslogtreecommitdiff
path: root/tests/amt
diff options
context:
space:
mode:
authorMax Nanis2026-02-19 02:43:23 -0500
committerMax Nanis2026-02-19 02:43:23 -0500
commitf0f96f83c2630e890a2cbcab53f77fd4c37e1684 (patch)
treec6d2cb092e76bf5d499e0ea9949508d6b22164fd /tests/amt
parent3eaa56f0306ead818f64c3d99fc6d230d9b970a4 (diff)
downloadamt-jb-f0f96f83c2630e890a2cbcab53f77fd4c37e1684.tar.gz
amt-jb-f0f96f83c2630e890a2cbcab53f77fd4c37e1684.zip
Models, Project files, some pytests, requirements.. etcHEADmaster
Diffstat (limited to 'tests/amt')
-rw-r--r--tests/amt/__init__.py0
-rw-r--r--tests/amt/conftest.py0
-rw-r--r--tests/amt/test_models.py41
3 files changed, 41 insertions, 0 deletions
diff --git a/tests/amt/__init__.py b/tests/amt/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/amt/__init__.py
diff --git a/tests/amt/conftest.py b/tests/amt/conftest.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/amt/conftest.py
diff --git a/tests/amt/test_models.py b/tests/amt/test_models.py
new file mode 100644
index 0000000..c2a61b5
--- /dev/null
+++ b/tests/amt/test_models.py
@@ -0,0 +1,41 @@
+import copy
+
+import pytest
+
+from jb.models.assignment import Assignment
+
+
+@pytest.fixture
+def get_assignment_response_bad_tsid(
+ get_assignment_response, amt_worker_id, amt_assignment_id
+):
+ res = copy.deepcopy(get_assignment_response)
+ res["Assignment"]["Answer"] = (
+ '<?xml version="1.0" encoding="UTF-8"?>\n'
+ '<QuestionFormAnswers xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionFormAnswers.xsd">\n '
+ "<Answer>\n <QuestionIdentifier>amt_worker_id</QuestionIdentifier>\n "
+ f" <FreeText>{amt_worker_id}</FreeText>\n </Answer>\n <Answer>\n "
+ " <QuestionIdentifier>amt_assignment_id</QuestionIdentifier>\n "
+ f" <FreeText>{amt_assignment_id}</FreeText>\n </Answer>\n "
+ f" <Answer>\n <QuestionIdentifier>tsid</QuestionIdentifier>\n abc123 <FreeText></FreeText>\n </Answer>\n"
+ f"</QuestionFormAnswers>"
+ )
+ return res
+
+def test_get_assignment(get_assignment_response):
+ assignment = Assignment.from_amt_get_assignment(
+ get_assignment_response["Assignment"]
+ )
+ assert assignment.tsid is not None
+
+def test_get_assignment_no_tsid(get_assignment_response_no_tsid):
+ assignment = Assignment.from_amt_get_assignment(
+ get_assignment_response_no_tsid["Assignment"]
+ )
+ assert assignment.tsid is None
+
+def test_get_assignment_bad_tsid(get_assignment_response_bad_tsid):
+ assignment = Assignment.from_amt_get_assignment(
+ get_assignment_response_bad_tsid["Assignment"]
+ )
+ assert assignment.tsid is None \ No newline at end of file