aboutsummaryrefslogtreecommitdiff
path: root/tests/models/legacy/test_user_question_answer_in.py
diff options
context:
space:
mode:
authorMax Nanis2026-08-26 16:46:45 -0700
committerMax Nanis2026-08-26 16:46:45 -0700
commitcf239865ce440e1a71ee2360514eaeb018620ac9 (patch)
tree1fefff4a0bbf10df6431e541aa5a3ff5e76f0663 /tests/models/legacy/test_user_question_answer_in.py
parent47ea200eac0eaa7bef02f6ebb05de9afad5ee0d7 (diff)
downloadgeneralresearch-cf239865ce440e1a71ee2360514eaeb018620ac9.tar.gz
generalresearch-cf239865ce440e1a71ee2360514eaeb018620ac9.zip
Ruff afternoon!
Diffstat (limited to 'tests/models/legacy/test_user_question_answer_in.py')
-rw-r--r--tests/models/legacy/test_user_question_answer_in.py54
1 files changed, 21 insertions, 33 deletions
diff --git a/tests/models/legacy/test_user_question_answer_in.py b/tests/models/legacy/test_user_question_answer_in.py
index 313862c..3fdaa05 100644
--- a/tests/models/legacy/test_user_question_answer_in.py
+++ b/tests/models/legacy/test_user_question_answer_in.py
@@ -1,9 +1,22 @@
+from __future__ import annotations
+
import json
+from collections.abc import Callable
+from datetime import datetime
from decimal import Decimal
from uuid import uuid4
import pytest
+from generalresearch.managers.thl.user_manager.user_manager import UserManager
+from generalresearch.models import Source
+from generalresearch.models.legacy.questions import (
+ UserQuestionAnswers,
+)
+from generalresearch.models.thl.product import Product
+from generalresearch.models.thl.session import Session, Wall
+from generalresearch.models.thl.user import User
+
class TestUserQuestionAnswers:
"""This is for the GRS POST submission that may contain multiple
@@ -15,21 +28,11 @@ class TestUserQuestionAnswers:
def test_json_init(
self,
- product_manager: ProductManager,
- user_manager,
- session_manager,
- wall_manager,
user_factory: Callable[..., User],
product: Product,
- session_factory,
- utc_hour_ago,
+ session_factory: Callable[..., Session],
+ utc_hour_ago: datetime,
):
- from generalresearch.models import Source
- from generalresearch.models.legacy.questions import (
- UserQuestionAnswers,
- )
- from generalresearch.models.thl.session import Session, Wall
- from generalresearch.models.thl.user import User
u: User = user_factory(product=product)
@@ -61,14 +64,7 @@ class TestUserQuestionAnswers:
def test_simple_validation_errors(
self,
- product_manager: ProductManager,
- user_manager,
- session_manager,
- wall_manager,
):
- from generalresearch.models.legacy.questions import (
- UserQuestionAnswers,
- )
with pytest.raises(ValueError):
UserQuestionAnswers.model_validate(
@@ -118,7 +114,7 @@ class TestUserQuestionAnswers:
with pytest.raises(ValueError):
answers = [
- {"question_id": uuid4().hex, "answer": ["a"]} for i in range(101)
+ {"question_id": uuid4().hex, "answer": ["a"]} for _ in range(101)
]
UserQuestionAnswers.model_validate(
{
@@ -143,9 +139,6 @@ class TestUserQuestionAnswers:
# TODO: depending on if or how many of these types of errors actually
# occur, we could get fancy and just drop one of them. I don't
# think this is worth exploring yet unless we see if it's a problem.
- from generalresearch.models.legacy.questions import (
- UserQuestionAnswers,
- )
consistent_qid = uuid4().hex
with pytest.raises(ValueError) as cm:
@@ -165,11 +158,11 @@ class TestUserQuestionAnswers:
def test_allow_answer_failures_silent(
self,
- user_manager,
+ user_manager: UserManager,
product: Product,
user_factory: Callable[..., User],
- utc_hour_ago,
- session_factory,
+ utc_hour_ago: datetime,
+ session_factory: Callable[..., Session],
):
"""
There are many instances where suppliers may be submitting answers
@@ -177,11 +170,6 @@ class TestUserQuestionAnswers:
that one QuestionAnswerIn without "loosing" any of the other
QuestionAnswerIn items that they provided.
"""
- from generalresearch.models.legacy.questions import (
- UserQuestionAnswers,
- )
- from generalresearch.models.thl.session import Session, Wall
- from generalresearch.models.thl.user import User
u: User = user_factory(product=product)
@@ -286,7 +274,7 @@ class TestUserQuestionAnswerIn:
UserQuestionAnswerIn,
)
- answer = [uuid4().hex[:6] for i in range(11)]
+ answer = [uuid4().hex[:6] for _ in range(11)]
with pytest.raises(ValueError) as cm:
UserQuestionAnswerIn.model_validate(
{"question_id": uuid4().hex, "answer": answer}
@@ -298,7 +286,7 @@ class TestUserQuestionAnswerIn:
UserQuestionAnswerIn,
)
- answer = ["aaa" for i in range(5)]
+ answer = ["aaa" for _ in range(5)]
with pytest.raises(ValueError):
UserQuestionAnswerIn.model_validate(
{"question_id": uuid4().hex, "answer": answer}