diff options
| author | stuppie | 2026-09-06 19:32:31 -0600 |
|---|---|---|
| committer | stuppie | 2026-09-06 19:32:31 -0600 |
| commit | 0645e930703a6fa01ef913a3a93720aedbe6a9f5 (patch) | |
| tree | e37620232721852051acc927705d905beeaa068d | |
| parent | 282e224429516efbf00f6c876bfbb82be00bb266 (diff) | |
| download | generalresearch-0645e930703a6fa01ef913a3a93720aedbe6a9f5.tar.gz generalresearch-0645e930703a6fa01ef913a3a93720aedbe6a9f5.zip | |
GrlIqDataManager: something changed but I can't really figure out what; not sure if its a test issue or really broken, but either way results and category_result should be excluded from model dump
| -rw-r--r-- | generalresearch/grliq/managers/forensic_data.py | 55 | ||||
| -rw-r--r-- | test_utils/grliq/conftest.py | 2 | ||||
| -rw-r--r-- | test_utils/models/thl/conftest.py | 4 |
3 files changed, 33 insertions, 28 deletions
diff --git a/generalresearch/grliq/managers/forensic_data.py b/generalresearch/grliq/managers/forensic_data.py index f523b6e..0810723 100644 --- a/generalresearch/grliq/managers/forensic_data.py +++ b/generalresearch/grliq/managers/forensic_data.py @@ -17,13 +17,11 @@ from generalresearch.grliq.models.forensic_result import ( from generalresearch.models.custom_types import UUIDStr if TYPE_CHECKING: - from generalresearch.models.thl.user import User from generalresearch.pg_helper import PostgresConfig class GrlIqDataManager: - def __init__(self, postgres_config: PostgresConfig): self.postgres_config = postgres_config @@ -36,7 +34,15 @@ class GrlIqDataManager: is_attempt_allowed: bool | None = None, ) -> GrlIqData: - data = iq_data.model_dump_sql(exclude={"events", "mouse_events", "timing_data"}) + data = iq_data.model_dump_sql( + exclude={ + "events", + "mouse_events", + "timing_data", + "results", + "category_result", + } + ) data["result_data"] = None if result_data: @@ -476,16 +482,16 @@ class GrlIqDataManager: product_ids = None if product_ids: - assert ( - users is None and user is None and product_id is None - ), "user, users, product_id, and product_ids are mutually exclusive" + assert users is None and user is None and product_id is None, ( + "user, users, product_id, and product_ids are mutually exclusive" + ) params["product_ids"] = list(set(product_ids)) filters.append("d.product_id = ANY(%(product_ids)s::UUID[])") if product_id: - assert ( - users is None and user is None and product_ids is None - ), "user, users, product_id, and product_ids are mutually exclusive" + assert users is None and user is None and product_ids is None, ( + "user, users, product_id, and product_ids are mutually exclusive" + ) params["product_id"] = product_id filters.append("d.product_id = %(product_id)s") @@ -506,12 +512,12 @@ class GrlIqDataManager: ) if created_between: - assert ( - created_after is None - ), "Cannot pass both created_after and created_between" - assert ( - created_before is None - ), "Cannot pass both created_before and created_between" + assert created_after is None, ( + "Cannot pass both created_after and created_between" + ) + assert created_before is None, ( + "Cannot pass both created_before and created_between" + ) params["created_after"] = created_between[0] params["created_before"] = created_between[1] filters.append( @@ -519,9 +525,9 @@ class GrlIqDataManager: ) if user: - assert ( - product_ids is None and users is None - ), "user, users, and product_ids are mutually exclusive" + assert product_ids is None and users is None, ( + "user, users, and product_ids are mutually exclusive" + ) params["product_id"] = user.product_id params["product_user_id"] = user.product_user_id filters.append( @@ -529,9 +535,9 @@ class GrlIqDataManager: ) if users: - assert ( - product_ids is None and user is None - ), "user, users, and product_ids are mutually exclusive" + assert product_ids is None and user is None, ( + "user, users, and product_ids are mutually exclusive" + ) user_args = ", ".join( [f"(%(bp_{i})s, %(bpuid_{i})s)" for i in range(len(users))] ) @@ -649,9 +655,9 @@ class GrlIqDataManager: if product_ids: # It doesn't use the (product_id, created_at) index with multiple product_ids - assert ( - offset == 0 - ), "Cannot paginate using product_ids, use product_id instead" + assert offset == 0, ( + "Cannot paginate using product_ids, use product_id instead" + ) filter_str, params = self.make_filter_str( session_uuid=session_uuid, @@ -682,7 +688,6 @@ class GrlIqDataManager: res: list[dict[str, Any]] = c.fetchall() # type: ignore for x in res: - if "data" in x: self.temporary_add_missing_fields(x["data"]) x["data"]["id"] = x["id"] diff --git a/test_utils/grliq/conftest.py b/test_utils/grliq/conftest.py index f399a99..249b068 100644 --- a/test_utils/grliq/conftest.py +++ b/test_utils/grliq/conftest.py @@ -90,7 +90,7 @@ def grliq_data_factory( """ if save: - res: GrlIqData = grliq_data_list[int(is_attempt_allowed)]["data"] + res: dict = grliq_data_list[int(is_attempt_allowed)] product_id = product_id or uuid4().hex product_user_id = product_user_id or uuid4().hex diff --git a/test_utils/models/thl/conftest.py b/test_utils/models/thl/conftest.py index 8b3ab32..fe2b4f5 100644 --- a/test_utils/models/thl/conftest.py +++ b/test_utils/models/thl/conftest.py @@ -498,7 +498,7 @@ def unsaved_ip_geoname(ip_geoname_factory: Callable[..., IPGeoname]) -> IPGeonam @pytest.fixture def ip_information_factory( - ipinformation_manager: IPInformationManager, + ip_information_manager: IPInformationManager, ) -> Callable[..., IPInformation]: def _inner( @@ -530,7 +530,7 @@ def ip_information_factory( ) -> IPInformation: if save: - return ipinformation_manager.create( + return ip_information_manager.create( ip=ip or fake.ipv4_public(), geoname_id=geoname_id, country_iso=country_iso or fake.country_code(), |
