Skip to content

Commit

Permalink
Add description / filter out test agencies from respose
Browse files Browse the repository at this point in the history
  • Loading branch information
mikehmassgov committed Dec 3, 2024
1 parent 62996c7 commit 0efa8be
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 20 deletions.
40 changes: 22 additions & 18 deletions api/src/api/agencies_v1/agency_schema.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from src.api.schemas.extension import Schema, fields
from src.api.schemas.response_schema import AbstractResponseSchema, PaginationMixinSchema
from src.constants.lookup_constants import AgencyDownloadFileType
from src.pagination.pagination_schema import generate_pagination_schema


Expand All @@ -21,15 +22,23 @@ class AgencyListRequestSchema(Schema):
class AgencyContactInfoSchema(Schema):
"""Schema for agency contact information"""

contact_name = fields.String()
address_line_1 = fields.String()
address_line_2 = fields.String(allow_none=True)
city = fields.String()
state = fields.String()
zip_code = fields.String()
phone_number = fields.String()
primary_email = fields.String()
secondary_email = fields.String(allow_none=True)
contact_name = fields.String(metadata={"description": "Full name of the agency contact person"})
address_line_1 = fields.String(metadata={"description": "Primary street address of the agency"})
address_line_2 = fields.String(
allow_none=True,
metadata={"description": "Additional address information (suite, unit, etc.)"},
)
city = fields.String(metadata={"description": "City where the agency is located"})
state = fields.String(metadata={"description": "State where the agency is located"})
zip_code = fields.String(metadata={"description": "Postal code for the agency address"})
phone_number = fields.String(metadata={"description": "Contact phone number for the agency"})
primary_email = fields.String(
metadata={"description": "Main email address for agency communications"}
)
secondary_email = fields.String(
allow_none=True,
metadata={"description": "Alternative email address for agency communications"},
)


class AgencyResponseSchema(Schema):
Expand All @@ -54,16 +63,11 @@ class AgencyResponseSchema(Schema):
is_image_workspace_enabled = fields.Boolean()
is_validation_workspace_enabled = fields.Boolean()

# Optional fields
ldap_group = fields.String(allow_none=True)
description = fields.String(allow_none=True)
label = fields.String(allow_none=True)

# Related agency info
top_level_agency_id = fields.Integer(allow_none=True)

# File types as a list of strings
agency_download_file_types = fields.List(fields.String())
agency_download_file_types = fields.List(
fields.Enum(AgencyDownloadFileType),
metadata={"description": "List of download file types supported by the agency"},
)

# Add timestamps from TimestampMixin
created_at = fields.DateTime()
Expand Down
3 changes: 3 additions & 0 deletions api/src/services/agencies_v1/get_agencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ def get_agencies(
) -> Tuple[Sequence[Agency], PaginationInfo]:
stmt = select(Agency).options(joinedload("*"))

# Exclude test agencies
stmt = stmt.where(Agency.is_test_agency != True) # noqa: E712

if list_params.filters:
if list_params.filters.agency_name:
stmt = stmt.where(Agency.agency_name == list_params.filters.agency_name)
Expand Down
7 changes: 5 additions & 2 deletions api/tests/src/api/agencies_v1/test_agencies_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ def test_agencies_get_default_dates(
self, client, api_auth_token, enable_factory_create, db_session
):
# These should return in the default date range
AgencyFactory.create_batch(20)
AgencyFactory.create_batch(7)

# These should be excluded
AgencyFactory.create_batch(3, is_test_agency=True)

payload = {
"filters": {},
Expand All @@ -36,4 +39,4 @@ def test_agencies_get_default_dates(
response = client.post("/v1/agencies", headers={"X-Auth": api_auth_token}, json=payload)
assert response.status_code == 200
data = response.json["data"]
assert len(data) == 10
assert len(data) == 7

0 comments on commit 0efa8be

Please sign in to comment.