diff --git a/app/models.py b/app/models.py index de467301..538d3ed8 100644 --- a/app/models.py +++ b/app/models.py @@ -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), diff --git a/tests/commands/test_commands.py b/tests/commands/test_commands.py index af72fc14..bd6d69e6 100644 --- a/tests/commands/test_commands.py +++ b/tests/commands/test_commands.py @@ -90,12 +90,10 @@ 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( @@ -103,9 +101,8 @@ def test_send_reminders_external_onboarding( ): 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()