diff --git a/scripts/send_application_on_closure.py b/scripts/send_application_on_closure.py index 6c432f84..5cde6bb3 100755 --- a/scripts/send_application_on_closure.py +++ b/scripts/send_application_on_closure.py @@ -5,7 +5,6 @@ from distutils.util import strtobool - sys.path.insert(1, ".") import external_services # noqa: E402 @@ -41,12 +40,9 @@ def send_incomplete_applications_after_deadline( - application_id (str, required if `single_application` is True): The application_id to process. """ - current_date_time = ( - datetime.now().replace(microsecond=0).strftime("%Y-%m-%d %H:%M:%S") - ) - fund_rounds = get_fund_round(fund_id, round_id) - if current_date_time > fund_rounds.get("deadline"): + deadline = datetime.strptime(fund_rounds.get("deadline"), "%Y-%m-%dT%H:%M:%S") + if datetime.now() > deadline: fund_data = get_fund(fund_id) search_params = { "status_only": ["NOT_STARTED", "IN_PROGRESS", "COMPLETED"], diff --git a/tests/test_send_app_on_closure.py b/tests/test_send_app_on_closure.py index 94846217..a426b1c3 100644 --- a/tests/test_send_app_on_closure.py +++ b/tests/test_send_app_on_closure.py @@ -31,7 +31,7 @@ def test_send_apps_bad_account_id( mocker.patch( "scripts.send_application_on_closure.get_fund_round", return_value={ - "deadline": "2022-12-01 12:00:00", + "deadline": "2022-12-01T12:00:00", "round_name": "COF R2W2", }, ) @@ -63,7 +63,7 @@ def test_send_apps_no_apps( mocker.patch( "scripts.send_application_on_closure.get_fund_round", - return_value={"deadline": "2022-01-01 12:00:00"}, + return_value={"deadline": "2022-01-01T12:00:00"}, ) result = send_incomplete_applications_after_deadline(fund_id, round_id, True) @@ -76,7 +76,7 @@ def test_send_apps_send_emails_is_false( ): mocker.patch( "scripts.send_application_on_closure.get_fund_round", - return_value={"deadline": "2022-01-01 12:00:00"}, + return_value={"deadline": "2022-01-01T12:00:00"}, ) result = send_incomplete_applications_after_deadline( @@ -98,7 +98,7 @@ def test_send_apps_one_to_send_not_started( mocker.patch( "scripts.send_application_on_closure.get_fund_round", return_value={ - "deadline": "2022-12-01 12:00:00", + "deadline": "2022-12-01T12:00:00", "round_name": "COF R2W2", }, ) @@ -121,7 +121,7 @@ def test_send_single_application( mocker.patch( "scripts.send_application_on_closure.get_fund_round", return_value={ - "deadline": "2022-12-01 12:00:00", + "deadline": "2022-12-01T12:00:00", "round_name": "COF R2W2", }, ) @@ -152,7 +152,7 @@ def test_send_apps_one_to_send_in_progress( mocker.patch( "scripts.send_application_on_closure.get_fund_round", return_value={ - "deadline": "2022-12-01 12:00:00", + "deadline": "2022-12-01T12:00:00", "round_name": "COF R2W2", }, ) @@ -176,7 +176,7 @@ def test_send_apps_two_to_send( mocker.patch( "scripts.send_application_on_closure.get_fund_round", return_value={ - "deadline": "2022-12-01 12:00:00", + "deadline": "2022-12-01T12:00:00", "round_name": "COF R2W2", }, ) @@ -210,7 +210,7 @@ def test_send_apps_one_to_send_one_bad_id( mocker.patch( "scripts.send_application_on_closure.get_fund_round", return_value={ - "deadline": "2022-12-01 12:00:00", + "deadline": "2022-12-01T12:00:00", "round_name": "COF R2W2", }, ) @@ -234,7 +234,7 @@ def test_send_apps_before_deadline(self, mocker, app, mocked_get_fund): mocker.patch( "scripts.send_application_on_closure.get_fund_round", - return_value={"deadline": "2025-01-01 12:00:00"}, + return_value={"deadline": "2025-01-01T12:00:00"}, ) result = send_incomplete_applications_after_deadline(fund_id, round_id)