Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
eastandwestwind committed Jun 14, 2024
1 parent 4d29ef6 commit dec5f1d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
11 changes: 7 additions & 4 deletions src/fides/api/api/v1/endpoints/messaging_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
TestMessagingStatusMessage,
MessagingTemplateWithPropertiesSummary,
MessagingTemplateWithPropertiesDetail,
MessagingTemplateWithPropertiesBodyParams, MessagingTemplateDefault,
MessagingTemplateWithPropertiesBodyParams,
MessagingTemplateDefault,
)
from fides.api.schemas.messaging.messaging_secrets_docs_only import (
possible_messaging_secrets,
Expand Down Expand Up @@ -601,7 +602,9 @@ def get_property_specific_messaging_templates_summary(
"""
# First save any missing template types to db
save_defaults_for_all_messaging_template_types(db)
ordered_templates = MessagingTemplate.query(db=db).order_by(MessagingTemplate.created_at.desc())
ordered_templates = MessagingTemplate.query(db=db).order_by(
MessagingTemplate.created_at.desc()
)
# Now return all templates
return paginate(
ordered_templates,
Expand Down Expand Up @@ -636,7 +639,7 @@ def create_property_specific_messaging_template(
*,
db: Session = Depends(deps.get_db),
messaging_template_create_body: MessagingTemplateWithPropertiesBodyParams,
) -> Optional[MessagingTemplateWithPropertiesDetail]:
) -> Optional[MessagingTemplate]:
"""
Creates property-specific messaging template by template type.
"""
Expand Down Expand Up @@ -664,7 +667,7 @@ def update_property_specific_messaging_template(
*,
db: Session = Depends(deps.get_db),
messaging_template_update_body: MessagingTemplateWithPropertiesBodyParams,
) -> Optional[MessagingTemplateWithPropertiesDetail]:
) -> Optional[MessagingTemplate]:
"""
Updates property-specific messaging template by template id.
"""
Expand Down
6 changes: 4 additions & 2 deletions src/fides/api/service/messaging/messaging_crud_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
MessagingConfigRequest,
MessagingConfigResponse,
MessagingTemplateWithPropertiesBodyParams,
MessagingTemplateWithPropertiesDetail, MessagingTemplateDefault,
MessagingTemplateDefault,
)


Expand Down Expand Up @@ -400,7 +400,9 @@ def save_defaults_for_all_messaging_template_types(
We retrieve all templates from the db, writing the default templates that do not already exist. This way, we can
have a pure Query obj to provide to the endpoint pagination fn.
"""
logger.info("Saving any messaging template defaults that don't yet exist in the DB...")
logger.info(
"Saving any messaging template defaults that don't yet exist in the DB..."
)

for (
template_type,
Expand Down
23 changes: 17 additions & 6 deletions tests/ops/api/v1/endpoints/test_messaging_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
BasicMessagingTemplateResponse,
MessagingTemplateWithPropertiesSummary,
MessagingTemplateWithPropertiesDetail,
MessagingActionType, MessagingTemplateDefault,
MessagingActionType,
MessagingTemplateDefault,
)
from fides.common.api.scope_registry import (
MESSAGING_CREATE_OR_UPDATE,
Expand Down Expand Up @@ -2083,7 +2084,10 @@ def test_get_messaging_templates_summary_no_db_templates(
assert len(response_body["items"]) == 6

# Validate the response conforms to the expected model
[MessagingTemplateWithPropertiesSummary(**item) for item in response_body["items"]]
[
MessagingTemplateWithPropertiesSummary(**item)
for item in response_body["items"]
]

def test_get_all_messaging_templates_summary_some_db_templates(
self,
Expand All @@ -2100,7 +2104,10 @@ def test_get_all_messaging_templates_summary_some_db_templates(
assert len(response_body["items"]) == 6

# Validate the response conforms to the expected model
[MessagingTemplateWithPropertiesSummary(**item) for item in response_body["items"]]
[
MessagingTemplateWithPropertiesSummary(**item)
for item in response_body["items"]
]

def test_get_all_messaging_templates_summary_all_db_templates(
self, db: Session, url, api_client: TestClient, generate_auth_header, property_a
Expand All @@ -2127,7 +2134,10 @@ def test_get_all_messaging_templates_summary_all_db_templates(
assert len(response_body["items"]) == 6

# Validate the response conforms to the expected model
[MessagingTemplateWithPropertiesSummary(**item) for item in response_body["items"]]
[
MessagingTemplateWithPropertiesSummary(**item)
for item in response_body["items"]
]


class TestGetMessagingTemplateDefaultByTemplateType:
Expand Down Expand Up @@ -2468,6 +2478,7 @@ def test_delete_messaging_template_by_id_success(
assert response.status_code == 204

db.expunge_all()
template = db.query(MessagingTemplate).filter_by(id=messaging_template.id).first()
template = (
db.query(MessagingTemplate).filter_by(id=messaging_template.id).first()
)
assert template is None

0 comments on commit dec5f1d

Please sign in to comment.