This commit is contained in:
Kenneth Kehl
2024-08-01 10:38:58 -07:00
parent b5014bd0ec
commit 2dd3ebc657
4 changed files with 15 additions and 19 deletions

View File

@@ -305,7 +305,7 @@
"filename": "tests/app/service/test_rest.py", "filename": "tests/app/service/test_rest.py",
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8", "hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
"is_verified": false, "is_verified": false,
"line_number": 1274, "line_number": 1275,
"is_secret": false "is_secret": false
} }
], ],
@@ -384,5 +384,5 @@
} }
] ]
}, },
"generated_at": "2024-07-22T21:27:35Z" "generated_at": "2024-08-01T17:38:39Z"
} }

View File

@@ -592,14 +592,15 @@ def process_row_from_job(job_id, job_row_number):
@notify_command(name="download-csv-file-by-name") @notify_command(name="download-csv-file-by-name")
@click.argument("csv_filename") @click.option("-f", "--csv_filename", required=True, help="S3 file location")
def download_csv_file_by_name(csv_filename): def download_csv_file_by_name(csv_filename):
# poetry run flask command download-csv-file-by-name <s3 file location> # poetry run flask command download-csv-file-by-name -f <s3 file location>
# cf run-task notify-api-production --command "flask command download-csv-file-by-name <s3 location>" # cf run-task notify-api-production --command "flask command download-csv-file-by-name -f <s3 location>"
bucket_name = current_app.config["CSV_UPLOAD_BUCKET"]["bucket"] bucket_name = current_app.config["CSV_UPLOAD_BUCKET"]["bucket"]
access_key = current_app.config["CSV_UPLOAD_BUCKET"]["access_key_id"] access_key = current_app.config["CSV_UPLOAD_BUCKET"]["access_key_id"]
secret = current_app.config["CSV_UPLOAD_BUCKET"]["secret_access_key"] secret = current_app.config["CSV_UPLOAD_BUCKET"]["secret_access_key"]
region = current_app.config["CSV_UPLOAD_BUCKET"]["region"] region = current_app.config["CSV_UPLOAD_BUCKET"]["region"]
s3.download_from_s3( s3.download_from_s3(
bucket_name, csv_filename, "download.csv", access_key, secret, region bucket_name, csv_filename, "download.csv", access_key, secret, region
) )

View File

@@ -1770,9 +1770,6 @@ def test_get_all_notifications_for_service_in_order_with_post_request(
assert response.status_code == 200 assert response.status_code == 200
@pytest.mark.skip(
reason="We can't search on recipient if recipient is not kept in the db"
)
def test_get_all_notifications_for_service_filters_notifications_when_using_post_request( def test_get_all_notifications_for_service_filters_notifications_when_using_post_request(
client, notify_db_session client, notify_db_session
): ):
@@ -1808,7 +1805,6 @@ def test_get_all_notifications_for_service_filters_notifications_when_using_post
"page": 1, "page": 1,
"template_type": [TemplateType.SMS], "template_type": [TemplateType.SMS],
"status": [NotificationStatus.CREATED, NotificationStatus.SENDING], "status": [NotificationStatus.CREATED, NotificationStatus.SENDING],
"to": "0855",
} }
response = client.post( response = client.post(
@@ -1818,7 +1814,7 @@ def test_get_all_notifications_for_service_filters_notifications_when_using_post
) )
resp = json.loads(response.get_data(as_text=True)) resp = json.loads(response.get_data(as_text=True))
assert len(resp["notifications"]) == 1 assert len(resp["notifications"]) == 2
assert resp["notifications"][0]["to"] == "1" assert resp["notifications"][0]["to"] == "1"
assert resp["notifications"][0]["status"] == returned_notification.status assert resp["notifications"][0]["status"] == returned_notification.status
assert response.status_code == 200 assert response.status_code == 200

View File

@@ -428,23 +428,22 @@ def test_promote_user_to_platform_admin(
assert user.platform_admin is True assert user.platform_admin is True
def test_download_csv_file_by_name(notify_api, sample_platform_admin): def test_download_csv_file_by_name(notify_api, mocker):
assert sample_platform_admin.platform_admin is True mock_download = mocker.patch("app.commands.s3.download_from_s3")
notify_api.test_cli_runner().invoke(
result = notify_api.test_cli_runner().invoke(
download_csv_file_by_name, download_csv_file_by_name,
[ [
"-f",
"NonExistentName", "NonExistentName",
], ],
) )
mock_download.assert_called_once()
# if we get a 404, it means that the file is not in s3 (of course)
# but we are making the call to s3, etc. so that part is working
assert "404" in str(result)
def test_promote_user_to_platform_admin_no_result_found( def test_promote_user_to_platform_admin_no_result_found(
notify_db_session, notify_api, sample_user notify_db_session,
notify_api,
sample_user,
): ):
assert sample_user.platform_admin is False assert sample_user.platform_admin is False