Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions src/api/endpoints/annotate/all/post/models/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,6 @@ def forbid_record_type_if_meta_url_or_individual_record(self):
raise FailedValidationException("record_type must be None if suggested_status is META_URL")
return self

@model_validator(mode="after")
def require_record_type_if_data_source(self):
if self.suggested_status == URLType.DATA_SOURCE and self.record_type is None:
raise FailedValidationException("record_type must be provided if suggested_status is DATA_SOURCE")
return self

@model_validator(mode="after")
def require_location_if_relevant(self):
if self.suggested_status not in [
URLType.META_URL,
URLType.DATA_SOURCE,
URLType.INDIVIDUAL_RECORD,
]:
return self
if len(self.location_ids) == 0:
raise FailedValidationException("location_ids must be provided if suggested_status is META_URL or DATA_SOURCE")
return self

@model_validator(mode="after")
def require_agency_id_if_relevant(self):
if self.suggested_status not in [
URLType.META_URL,
URLType.DATA_SOURCE,
URLType.INDIVIDUAL_RECORD,
]:
return self
if len(self.agency_ids) == 0:
raise FailedValidationException("agencies must be provided if suggested_status is META_URL or DATA_SOURCE")
return self

@model_validator(mode="after")
def forbid_all_else_if_not_relevant(self):
if self.suggested_status != URLType.NOT_RELEVANT:
Expand Down
50 changes: 0 additions & 50 deletions tests/automated/unit/api/test_all_annotation_post_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,42 +54,6 @@ class TestAllAnnotationPostInfoParams(BaseModel):
location_ids=[3, 4],
raise_exception=True
),
TestAllAnnotationPostInfoParams(
suggested_status=URLType.META_URL,
record_type=None,
agency_ids=[], # No agency IDs
location_ids=[3, 4],
raise_exception=True
),
TestAllAnnotationPostInfoParams(
suggested_status=URLType.META_URL,
record_type=None,
agency_ids=[1, 2],
location_ids=[], # No Location IDs
raise_exception=True
),
# Error Paths - Data Source
TestAllAnnotationPostInfoParams(
suggested_status=URLType.DATA_SOURCE,
record_type=None, # No record type
agency_ids=[1, 2],
location_ids=[3, 4],
raise_exception=True
),
TestAllAnnotationPostInfoParams(
suggested_status=URLType.DATA_SOURCE,
record_type=RecordType.ACCIDENT_REPORTS,
agency_ids=[], # No Agency IDs
location_ids=[3, 4],
raise_exception=True
),
TestAllAnnotationPostInfoParams(
suggested_status=URLType.DATA_SOURCE,
record_type=RecordType.ACCIDENT_REPORTS,
agency_ids=[1, 2],
location_ids=[], # No Location IDs
raise_exception=True
),
# Error Paths - Not Relevant
TestAllAnnotationPostInfoParams(
suggested_status=URLType.NOT_RELEVANT,
Expand Down Expand Up @@ -120,20 +84,6 @@ class TestAllAnnotationPostInfoParams(BaseModel):
location_ids=[],
raise_exception=True
),
TestAllAnnotationPostInfoParams(
suggested_status=URLType.INDIVIDUAL_RECORD,
record_type=None,
agency_ids=[1, 2], # Agency IDs Included
location_ids=[],
raise_exception=True
),
TestAllAnnotationPostInfoParams(
suggested_status=URLType.INDIVIDUAL_RECORD,
record_type=None,
agency_ids=[],
location_ids=[1, 2], # Location IDs included
raise_exception=True
)
]
)
def test_all_annotation_post_info(
Expand Down