Skip to content

Commit

Permalink
chore: Uncomment new code for external onboarding reminders, #439
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Oct 30, 2024
1 parent f2576a3 commit c89a1f8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
10 changes: 4 additions & 6 deletions app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,17 +763,15 @@ def pending_external_onboarding_reminder(cls, session: Session) -> "Query[Self]"
.. seealso:: :typer:`python-m-app-send-reminders`
"""
# lapsed_at = col(cls.borrower_submitted_at) + timedelta(days=app_settings.days_to_change_to_lapsed) # noqa: ERA001, E501
# days = app_settings.reminder_days_before_lapsed_for_external_onboarding # noqa: ERA001
remind_at = col(cls.borrower_submitted_at) + timedelta(days=1)
lapsed_at = col(cls.borrower_submitted_at) + timedelta(days=app_settings.days_to_change_to_lapsed)
days = app_settings.reminder_days_before_lapsed_for_external_onboarding

return (
session.query(cls)
.filter(
cls.status == ApplicationStatus.SUBMITTED,
# datetime.now() < lapsed_at, # noqa: ERA001
# lapsed_at <= datetime.now() + timedelta(days=days), # noqa: ERA001
remind_at <= datetime.now(),
datetime.now() < lapsed_at,
lapsed_at <= datetime.now() + timedelta(days=days),
col(cls.id).notin_(Message.application_by_type(MessageType.BORROWER_EXTERNAL_ONBOARDING_REMINDER)),
col(Lender.external_onboarding_url) != "",
col(cls.borrower_accessed_external_onboarding_at).is_(None),
Expand Down
15 changes: 6 additions & 9 deletions tests/commands/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,19 @@ def test_send_reminders_submit(session, mock_send_templated_email, accepted_appl
@pytest.mark.parametrize(
("seconds", "call_count"),
[
# (negative_offset, 0), # noqa: ERA001
# (positive_offset, 1), # noqa: ERA001
# (app_settings.reminder_days_before_lapsed_for_external_onboarding * 86_400 + negative_offset, 1), # noqa: ERA001, E501
# (app_settings.reminder_days_before_lapsed_for_external_onboarding * 86_400 + positive_offset, 0), # noqa: ERA001, E501
(86_400 + negative_offset, 0),
(86_400 + positive_offset, 1),
(negative_offset, 0),
(positive_offset, 1),
(app_settings.reminder_days_before_lapsed_for_external_onboarding * 86_400 + negative_offset, 1),
(app_settings.reminder_days_before_lapsed_for_external_onboarding * 86_400 + positive_offset, 0),
],
)
def test_send_reminders_external_onboarding(
session, mock_send_templated_email, submitted_application_external_onboarding, seconds, call_count
):
submitted_application_external_onboarding.borrower_submitted_at = (
datetime.now(submitted_application_external_onboarding.tz)
# - timedelta(days=app_settings.days_to_change_to_lapsed) # noqa: ERA001
# + timedelta(seconds=seconds) # noqa: ERA001
- timedelta(seconds=seconds)
- timedelta(days=app_settings.days_to_change_to_lapsed)
+ timedelta(seconds=seconds)
)
session.commit()

Expand Down

0 comments on commit c89a1f8

Please sign in to comment.