aboutsummaryrefslogtreecommitdiff
path: root/tests/models
diff options
context:
space:
mode:
authorMax Nanis2026-08-24 12:35:35 -0700
committerMax Nanis2026-08-24 12:35:35 -0700
commite2c5de703be45746bacaea4136f24440ff5a291c (patch)
tree9c3d9d448e56357feda24a4b0749370a9a33cb55 /tests/models
parentd48f04ab7f034b9b2039c42cd616d7d7851817b9 (diff)
downloadgeneralresearch-e2c5de703be45746bacaea4136f24440ff5a291c.tar.gz
generalresearch-e2c5de703be45746bacaea4136f24440ff5a291c.zip
Ruff std replacements
Diffstat (limited to 'tests/models')
-rw-r--r--tests/models/admin/test_report_request.py2
-rw-r--r--tests/models/custom_types/test_aware_datetime.py2
-rw-r--r--tests/models/custom_types/test_dsn.py1
-rw-r--r--tests/models/dynata/test_eligbility.py2
-rw-r--r--tests/models/gr/test_authentication.py2
-rw-r--r--tests/models/gr/test_business.py3
-rw-r--r--tests/models/innovate/test_question.py6
-rw-r--r--tests/models/legacy/test_user_question_answer_in.py4
-rw-r--r--tests/models/morning/test.py2
-rw-r--r--tests/models/network/test_mtr.py4
-rw-r--r--tests/models/network/test_nmap_parser.py1
-rw-r--r--tests/models/prodege/test_survey_participation.py2
-rw-r--r--tests/models/spectrum/test_question.py2
-rw-r--r--tests/models/spectrum/test_survey.py2
-rw-r--r--tests/models/spectrum/test_survey_manager.py2
-rw-r--r--tests/models/test_finance.py2
-rw-r--r--tests/models/thl/question/test_question_info.py2
-rw-r--r--tests/models/thl/test_adjustments.py30
-rw-r--r--tests/models/thl/test_contest/test_leaderboard_contest.py2
-rw-r--r--tests/models/thl/test_ledger.py2
-rw-r--r--tests/models/thl/test_payout.py5
-rw-r--r--tests/models/thl/test_product.py2
-rw-r--r--tests/models/thl/test_upkquestion.py12
-rw-r--r--tests/models/thl/test_user.py6
-rw-r--r--tests/models/thl/test_user_iphistory.py2
-rw-r--r--tests/models/thl/test_user_streak.py2
-rw-r--r--tests/models/thl/test_wall.py2
-rw-r--r--tests/models/thl/test_wall_session.py2
28 files changed, 40 insertions, 68 deletions
diff --git a/tests/models/admin/test_report_request.py b/tests/models/admin/test_report_request.py
index 4626ab4..5b2ff0d 100644
--- a/tests/models/admin/test_report_request.py
+++ b/tests/models/admin/test_report_request.py
@@ -1,4 +1,4 @@
-from datetime import UTC, datetime, timezone
+from datetime import UTC, datetime
import pandas as pd
import pytest
diff --git a/tests/models/custom_types/test_aware_datetime.py b/tests/models/custom_types/test_aware_datetime.py
index 043fba0..7c45710 100644
--- a/tests/models/custom_types/test_aware_datetime.py
+++ b/tests/models/custom_types/test_aware_datetime.py
@@ -1,7 +1,7 @@
from __future__ import annotations
import logging
-from datetime import UTC, datetime, timezone
+from datetime import UTC, datetime
import pytest
import pytz
diff --git a/tests/models/custom_types/test_dsn.py b/tests/models/custom_types/test_dsn.py
index 050976e..eb27526 100644
--- a/tests/models/custom_types/test_dsn.py
+++ b/tests/models/custom_types/test_dsn.py
@@ -1,4 +1,3 @@
-from typing import Optional
from uuid import uuid4
import pytest
diff --git a/tests/models/dynata/test_eligbility.py b/tests/models/dynata/test_eligbility.py
index 16cad26..27de5b3 100644
--- a/tests/models/dynata/test_eligbility.py
+++ b/tests/models/dynata/test_eligbility.py
@@ -1,4 +1,4 @@
-from datetime import UTC, datetime, timezone
+from datetime import UTC, datetime
class TestEligibility:
diff --git a/tests/models/gr/test_authentication.py b/tests/models/gr/test_authentication.py
index 51595a7..ac39e64 100644
--- a/tests/models/gr/test_authentication.py
+++ b/tests/models/gr/test_authentication.py
@@ -2,7 +2,7 @@ import binascii
import json
import os
from collections.abc import Callable
-from datetime import UTC, datetime, timezone
+from datetime import UTC, datetime
from random import randint
from uuid import uuid4
diff --git a/tests/models/gr/test_business.py b/tests/models/gr/test_business.py
index 716ec75..948acb3 100644
--- a/tests/models/gr/test_business.py
+++ b/tests/models/gr/test_business.py
@@ -1,7 +1,6 @@
import os
-from datetime import UTC, datetime, timedelta, timezone
+from datetime import UTC, datetime, timedelta
from decimal import Decimal
-from typing import Optional
from uuid import uuid4
import pandas as pd
diff --git a/tests/models/innovate/test_question.py b/tests/models/innovate/test_question.py
index 330f919..b0c2964 100644
--- a/tests/models/innovate/test_question.py
+++ b/tests/models/innovate/test_question.py
@@ -1,15 +1,15 @@
from generalresearch.models import Source
from generalresearch.models.innovate.question import (
InnovateQuestion,
- InnovateQuestionType,
InnovateQuestionOption,
+ InnovateQuestionType,
)
from generalresearch.models.thl.profiling.upk_question import (
- UpkQuestionSelectorTE,
UpkQuestion,
+ UpkQuestionChoice,
UpkQuestionSelectorMC,
+ UpkQuestionSelectorTE,
UpkQuestionType,
- UpkQuestionChoice,
)
diff --git a/tests/models/legacy/test_user_question_answer_in.py b/tests/models/legacy/test_user_question_answer_in.py
index 224334a..1904798 100644
--- a/tests/models/legacy/test_user_question_answer_in.py
+++ b/tests/models/legacy/test_user_question_answer_in.py
@@ -263,12 +263,12 @@ class TestUserQuestionAnswerIn:
UserQuestionAnswerIn,
)
- for qid in {
+ for qid in (
"2fbedb2b9f7647b09ff5e52fa119cc5e",
"4030c52371b04e80b64e058d9c5b82e9",
"a91cb1dea814480dba12d9b7b48696dd",
"1d1e2e8380ac474b87fb4e4c569b48df",
- }:
+ ):
# This is the UserAgent question which only allows a single answer
with pytest.raises(ValueError) as cm:
UserQuestionAnswerIn.model_validate(
diff --git a/tests/models/morning/test.py b/tests/models/morning/test.py
index 222cb93..7474766 100644
--- a/tests/models/morning/test.py
+++ b/tests/models/morning/test.py
@@ -1,4 +1,4 @@
-from datetime import UTC, datetime, timezone
+from datetime import UTC, datetime
from generalresearch.models.morning.question import MorningQuestion
diff --git a/tests/models/network/test_mtr.py b/tests/models/network/test_mtr.py
index 2965300..840a773 100644
--- a/tests/models/network/test_mtr.py
+++ b/tests/models/network/test_mtr.py
@@ -1,7 +1,7 @@
-from generalresearch.models.network.mtr.execute import execute_mtr
import faker
-from generalresearch.models.network.tool_run import ToolName, ToolClass
+from generalresearch.models.network.mtr.execute import execute_mtr
+from generalresearch.models.network.tool_run import ToolClass, ToolName
fake = faker.Faker()
diff --git a/tests/models/network/test_nmap_parser.py b/tests/models/network/test_nmap_parser.py
index abc83c9..7822380 100644
--- a/tests/models/network/test_nmap_parser.py
+++ b/tests/models/network/test_nmap_parser.py
@@ -4,6 +4,7 @@ import pytest
from generalresearch.models.network.nmap.parser import parse_nmap_xml
+
@pytest.fixture
def nmap_raw_output_2(request) -> str:
fp = os.path.join(request.config.rootpath, "data/nmaprun2.xml")
diff --git a/tests/models/prodege/test_survey_participation.py b/tests/models/prodege/test_survey_participation.py
index 3b35d0c..e1ba9ab 100644
--- a/tests/models/prodege/test_survey_participation.py
+++ b/tests/models/prodege/test_survey_participation.py
@@ -1,4 +1,4 @@
-from datetime import UTC, datetime, timedelta, timezone
+from datetime import UTC, datetime, timedelta
class TestProdegeParticipation:
diff --git a/tests/models/spectrum/test_question.py b/tests/models/spectrum/test_question.py
index 4f92961..57d260d 100644
--- a/tests/models/spectrum/test_question.py
+++ b/tests/models/spectrum/test_question.py
@@ -1,4 +1,4 @@
-from datetime import UTC, datetime, timezone
+from datetime import UTC, datetime
from generalresearch.models import Source
from generalresearch.models.spectrum.question import (
diff --git a/tests/models/spectrum/test_survey.py b/tests/models/spectrum/test_survey.py
index 5e095a3..7365c7e 100644
--- a/tests/models/spectrum/test_survey.py
+++ b/tests/models/spectrum/test_survey.py
@@ -1,4 +1,4 @@
-from datetime import UTC, datetime, timezone
+from datetime import UTC, datetime
from decimal import Decimal
diff --git a/tests/models/spectrum/test_survey_manager.py b/tests/models/spectrum/test_survey_manager.py
index 11970bf..ce26c44 100644
--- a/tests/models/spectrum/test_survey_manager.py
+++ b/tests/models/spectrum/test_survey_manager.py
@@ -1,6 +1,6 @@
import copy
import logging
-from datetime import UTC, datetime, timezone
+from datetime import UTC, datetime
from decimal import Decimal
from pymysql import IntegrityError
diff --git a/tests/models/test_finance.py b/tests/models/test_finance.py
index 6dcd441..3d3ff3a 100644
--- a/tests/models/test_finance.py
+++ b/tests/models/test_finance.py
@@ -1,5 +1,5 @@
from collections.abc import Callable
-from datetime import UTC, datetime, timedelta, timezone
+from datetime import UTC, datetime, timedelta
from itertools import product as iter_product
from random import randint
from uuid import uuid4
diff --git a/tests/models/thl/question/test_question_info.py b/tests/models/thl/question/test_question_info.py
index 945ee7a..b619fc3 100644
--- a/tests/models/thl/question/test_question_info.py
+++ b/tests/models/thl/question/test_question_info.py
@@ -1,6 +1,6 @@
from generalresearch.models.thl.profiling.upk_property import (
- UpkProperty,
ProfilingInfo,
+ UpkProperty,
)
diff --git a/tests/models/thl/test_adjustments.py b/tests/models/thl/test_adjustments.py
index c2c035d..30e9bce 100644
--- a/tests/models/thl/test_adjustments.py
+++ b/tests/models/thl/test_adjustments.py
@@ -1,5 +1,5 @@
from collections.abc import Callable
-from datetime import UTC, datetime, timedelta, timezone
+from datetime import UTC, datetime, timedelta
from decimal import Decimal
import pytest
@@ -426,7 +426,7 @@ class TestAdjustments:
s1 = session_factory(
user=user,
wall_count=1,
- wall_req_cpi=Decimal("1"),
+ wall_req_cpi=Decimal(1),
final_status=Status.COMPLETE,
started=utc_hour_ago,
)
@@ -525,7 +525,7 @@ class TestAdjustments:
s1 = session_factory(
user=user,
wall_count=1,
- wall_req_cpi=Decimal("1"),
+ wall_req_cpi=Decimal(1),
final_status=Status.COMPLETE,
started=utc_hour_ago,
)
@@ -534,13 +534,7 @@ class TestAdjustments:
status, status_code_1 = s1.determine_session_status()
thl_net, commission_amount, bp_pay, user_pay = s1.determine_payments()
s1.update(
- **{
- "status": status,
- "status_code_1": status_code_1,
- "finished": utc_hour_ago + timedelta(minutes=10),
- "payout": bp_pay,
- "user_payout": user_pay,
- }
+ status=status, status_code_1=status_code_1, finished=utc_hour_ago + timedelta(minutes=10), payout=bp_pay, user_payout=user_pay
)
w1.update(
adjusted_status=WallAdjustedStatus.ADJUSTED_TO_FAIL,
@@ -592,13 +586,7 @@ class TestAdjustments:
thl_net = Decimal(sum(w.cpi for w in s1.wall_events if w.is_visible_complete()))
payout = user.product.determine_bp_payment(thl_net=thl_net)
s1.update(
- **{
- "status": status,
- "status_code_1": status_code_1,
- "finished": utc_hour_ago + timedelta(minutes=25),
- "payout": payout,
- "user_payout": None,
- }
+ status=status, status_code_1=status_code_1, finished=utc_hour_ago + timedelta(minutes=25), payout=payout, user_payout=None
)
# Test. Adjust first fail to complete. Now we have 2 completes.
@@ -646,13 +634,7 @@ class TestAdjustments:
thl_net = Decimal(sum(w.cpi for w in s1.wall_events if w.is_visible_complete()))
payout = user.product.determine_bp_payment(thl_net)
s1.update(
- **{
- "status": status,
- "status_code_1": status_code_1,
- "finished": utc_hour_ago + timedelta(minutes=25),
- "payout": payout,
- "user_payout": None,
- }
+ status=status, status_code_1=status_code_1, finished=utc_hour_ago + timedelta(minutes=25), payout=payout, user_payout=None
)
# Test. Adjust complete to fail. Now we have 2 fails.
diff --git a/tests/models/thl/test_contest/test_leaderboard_contest.py b/tests/models/thl/test_contest/test_leaderboard_contest.py
index 3efcf2f..52a4bec 100644
--- a/tests/models/thl/test_contest/test_leaderboard_contest.py
+++ b/tests/models/thl/test_contest/test_leaderboard_contest.py
@@ -1,4 +1,4 @@
-from datetime import UTC, timezone
+from datetime import UTC
from uuid import uuid4
import pytest
diff --git a/tests/models/thl/test_ledger.py b/tests/models/thl/test_ledger.py
index 5edcc9d..7066180 100644
--- a/tests/models/thl/test_ledger.py
+++ b/tests/models/thl/test_ledger.py
@@ -1,4 +1,4 @@
-from datetime import UTC, datetime, timezone
+from datetime import UTC, datetime
from uuid import uuid4
import pytest
diff --git a/tests/models/thl/test_payout.py b/tests/models/thl/test_payout.py
index 7068a41..d0b0acc 100644
--- a/tests/models/thl/test_payout.py
+++ b/tests/models/thl/test_payout.py
@@ -5,14 +5,13 @@ from pydantic import ValidationError
from generalresearch.currency import USDCent
from generalresearch.models.gr import Team
+from generalresearch.models.gr.business import Business, BusinessAddress, BusinessType
from generalresearch.models.thl.payout import (
- BusinessPayoutEvent,
BrokerageProductPayoutEvent,
+ BusinessPayoutEvent,
)
from generalresearch.models.thl.wallet import PayoutType
-from generalresearch.models.gr.business import Business, BusinessAddress, BusinessType
-
class TestBusinessPayoutEvent:
diff --git a/tests/models/thl/test_product.py b/tests/models/thl/test_product.py
index 78bc10a..bc95c2d 100644
--- a/tests/models/thl/test_product.py
+++ b/tests/models/thl/test_product.py
@@ -3,7 +3,7 @@ from __future__ import annotations
import os
import shutil
from collections.abc import Callable
-from datetime import UTC, datetime, timedelta, timezone
+from datetime import UTC, datetime, timedelta
from decimal import Decimal
from uuid import uuid4
diff --git a/tests/models/thl/test_upkquestion.py b/tests/models/thl/test_upkquestion.py
index d32875c..99d7871 100644
--- a/tests/models/thl/test_upkquestion.py
+++ b/tests/models/thl/test_upkquestion.py
@@ -201,18 +201,10 @@ class TestUpkQuestion:
)
q = MorningQuestion(
- **{
- "id": "gender",
- "country_iso": "us",
- "language_iso": "eng",
- "name": "Gender",
- "text": "What is your gender?",
- "type": "s",
- "options": [
+ id="gender", country_iso="us", language_iso="eng", name="Gender", text="What is your gender?", type="s", options=[
{"id": "1", "text": "yes", "order": 1},
{"id": "2", "text": "no", "order": 2},
- ],
- }
+ ]
)
q.to_upk_question()
q = MorningQuestion(
diff --git a/tests/models/thl/test_user.py b/tests/models/thl/test_user.py
index a4f331a..aafce68 100644
--- a/tests/models/thl/test_user.py
+++ b/tests/models/thl/test_user.py
@@ -197,7 +197,7 @@ class TestUserProductUserID:
assert "Input should be a valid string" in str(cm.value)
with pytest.raises(ValueError) as cm:
- User(user_id=self.user_id, product_user_id=Decimal("0"))
+ User(user_id=self.user_id, product_user_id=Decimal(0))
assert "1 validation error for User" in str(cm.value)
assert "Input should be a valid string" in str(cm.value)
@@ -236,7 +236,7 @@ class TestUserProductUserID:
def test_invalid_chars_slash(self):
from generalresearch.models.thl.user import User
- product_user_id = f"{self.randomword(50)}\{self.randomword(50)}"
+ product_user_id = rf"{self.randomword(50)}\{self.randomword(50)}"
with pytest.raises(expected_exception=ValueError) as cm:
User(user_id=self.user_id, product_user_id=product_user_id)
assert "1 validation error for User" in str(cm.value)
@@ -310,7 +310,7 @@ class TestUserUUID:
assert "Input should be a valid string" in str(cm.value)
with pytest.raises(ValueError) as cm:
- User(user_id=self.user_id, uuid=Decimal("0"))
+ User(user_id=self.user_id, uuid=Decimal(0))
assert "1 validation error for User" in str(cm.value)
assert "Input should be a valid string" in str(cm.value)
diff --git a/tests/models/thl/test_user_iphistory.py b/tests/models/thl/test_user_iphistory.py
index 0f050b0..d6ade9d 100644
--- a/tests/models/thl/test_user_iphistory.py
+++ b/tests/models/thl/test_user_iphistory.py
@@ -1,4 +1,4 @@
-from datetime import UTC, datetime, timedelta, timezone
+from datetime import UTC, datetime, timedelta
from generalresearch.models.thl.user_iphistory import (
UserIPHistory,
diff --git a/tests/models/thl/test_user_streak.py b/tests/models/thl/test_user_streak.py
index 0cacd3e..26c5e25 100644
--- a/tests/models/thl/test_user_streak.py
+++ b/tests/models/thl/test_user_streak.py
@@ -1,8 +1,8 @@
from datetime import datetime, timedelta
+from zoneinfo import ZoneInfo
import pytest
from pydantic import ValidationError
-from zoneinfo import ZoneInfo
from generalresearch.models.thl.user_streak import (
StreakFulfillment,
diff --git a/tests/models/thl/test_wall.py b/tests/models/thl/test_wall.py
index 9e9483b..88914ac 100644
--- a/tests/models/thl/test_wall.py
+++ b/tests/models/thl/test_wall.py
@@ -1,4 +1,4 @@
-from datetime import UTC, datetime, timedelta, timezone
+from datetime import UTC, datetime, timedelta
from decimal import Decimal
from uuid import uuid4
diff --git a/tests/models/thl/test_wall_session.py b/tests/models/thl/test_wall_session.py
index 10f3cba..b39ad31 100644
--- a/tests/models/thl/test_wall_session.py
+++ b/tests/models/thl/test_wall_session.py
@@ -1,4 +1,4 @@
-from datetime import UTC, datetime, timedelta, timezone
+from datetime import UTC, datetime, timedelta
from decimal import Decimal
import pytest