aboutsummaryrefslogtreecommitdiff
path: root/tests/models/legacy
diff options
context:
space:
mode:
Diffstat (limited to 'tests/models/legacy')
-rw-r--r--tests/models/legacy/test_offerwall_parse_response.py2
-rw-r--r--tests/models/legacy/test_profiling_questions.py6
-rw-r--r--tests/models/legacy/test_user_question_answer_in.py54
3 files changed, 28 insertions, 34 deletions
diff --git a/tests/models/legacy/test_offerwall_parse_response.py b/tests/models/legacy/test_offerwall_parse_response.py
index b1c96ad..56ba077 100644
--- a/tests/models/legacy/test_offerwall_parse_response.py
+++ b/tests/models/legacy/test_offerwall_parse_response.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import json
from generalresearch.models import Source
diff --git a/tests/models/legacy/test_profiling_questions.py b/tests/models/legacy/test_profiling_questions.py
index 1afaa6b..6f781ae 100644
--- a/tests/models/legacy/test_profiling_questions.py
+++ b/tests/models/legacy/test_profiling_questions.py
@@ -1,7 +1,11 @@
+from __future__ import annotations
+
+from generalresearch.models.legacy.questions import UpkQuestionResponse
+
+
class TestUpkQuestionResponse:
def test_init(self):
- from generalresearch.models.legacy.questions import UpkQuestionResponse
s = (
'{"status": "success", "count": 7, "questions": [{"selector": "SL", "validation": {"patterns": [{'
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}