From b0bfd110b3b7656c7ca5487477b2cc8ce04bf8b0 Mon Sep 17 00:00:00 2001 From: Max Chis Date: Thu, 25 Sep 2025 12:08:17 -0400 Subject: [PATCH] Fix bugs --- src/api/endpoints/annotate/all/post/models/name.py | 3 ++- src/api/endpoints/annotate/all/post/query.py | 5 +++-- .../integration/api/annotate/all/test_happy_path.py | 5 +++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/api/endpoints/annotate/all/post/models/name.py b/src/api/endpoints/annotate/all/post/models/name.py index 9d71431e..4cc63682 100644 --- a/src/api/endpoints/annotate/all/post/models/name.py +++ b/src/api/endpoints/annotate/all/post/models/name.py @@ -1,7 +1,8 @@ -from pydantic import BaseModel +from pydantic import BaseModel, ConfigDict class AnnotationPostNameInfo(BaseModel): + model_config = ConfigDict(extra="forbid") new_name: str | None = None existing_name_id: int | None = None diff --git a/src/api/endpoints/annotate/all/post/query.py b/src/api/endpoints/annotate/all/post/query.py index e6186790..a27d6c6f 100644 --- a/src/api/endpoints/annotate/all/post/query.py +++ b/src/api/endpoints/annotate/all/post/query.py @@ -34,6 +34,9 @@ async def run(self, session: AsyncSession) -> None: # Add relevant annotation requester.add_relevant_annotation(self.post_info.suggested_status) + await requester.optionally_add_name_suggestion(self.post_info.name_info) + + # If not relevant, do nothing else if self.post_info.suggested_status == URLType.NOT_RELEVANT: return @@ -44,5 +47,3 @@ async def run(self, session: AsyncSession) -> None: requester.optionally_add_record_type(self.post_info.record_type) requester.add_agency_ids(self.post_info.agency_ids) - - await requester.optionally_add_name_suggestion(self.post_info.name_info) diff --git a/tests/automated/integration/api/annotate/all/test_happy_path.py b/tests/automated/integration/api/annotate/all/test_happy_path.py index a7183f17..4ecb9935 100644 --- a/tests/automated/integration/api/annotate/all/test_happy_path.py +++ b/tests/automated/integration/api/annotate/all/test_happy_path.py @@ -7,6 +7,7 @@ from src.api.endpoints.annotate.all.post.models.request import AllAnnotationPostInfo from src.core.enums import RecordType from src.db.models.impl.flag.url_validated.enums import URLType +from src.db.models.impl.link.user_name_suggestion.sqlalchemy import LinkUserNameSuggestion from src.db.models.impl.url.suggestion.agency.user import UserUrlAgencySuggestion from src.db.models.impl.url.suggestion.location.user.sqlalchemy import UserLocationSuggestion from src.db.models.impl.url.suggestion.name.sqlalchemy import URLNameSuggestion @@ -154,3 +155,7 @@ async def test_annotate_all( suggested_names: set[str] = {name_suggestion.suggestion for name_suggestion in name_suggestions} assert "New Name" in suggested_names + # Confirm 2 link user name suggestions + link_user_name_suggestions: list[LinkUserNameSuggestion] = await adb_client.get_all(LinkUserNameSuggestion) + assert len(link_user_name_suggestions) == 2 +