diff --git a/.gitignore b/.gitignore index 53cf8311..246e6ec9 100644 --- a/.gitignore +++ b/.gitignore @@ -53,6 +53,7 @@ coverage.xml *.py,cover .hypothesis/ .pytest_cache/ +bulk_import_results/ # Translations *.mo diff --git a/app/clients/aws/s3bucket.py b/app/clients/aws/s3bucket.py index 9028253a..1a111c02 100644 --- a/app/clients/aws/s3bucket.py +++ b/app/clients/aws/s3bucket.py @@ -116,11 +116,13 @@ def upload_ingest_json_to_s3( _LOGGER.info(os.getenv("BULK_IMPORT_BUCKET", "Not there")) ingest_upload_bucket = os.environ["BULK_IMPORT_BUCKET"] current_timestamp = datetime.now().strftime("%m-%d-%YT%H:%M:%S") + filename = f"{ingest_id}-{corpus_import_id}-{current_timestamp}.json" if ingest_upload_bucket == "skip": - with open(filename, "w") as f: - json.dump(data, f, indent=4) + os.makedirs("bulk_import_results", exist_ok=True) + with open(f"bulk_import_results/{filename}", "w") as file: + json.dump(data, file, indent=4) return s3_client = get_s3_client() diff --git a/tests/unit_tests/clients/aws/test_client.py b/tests/unit_tests/clients/aws/test_client.py index 8fc6dfce..e60dfa31 100644 --- a/tests/unit_tests/clients/aws/test_client.py +++ b/tests/unit_tests/clients/aws/test_client.py @@ -42,6 +42,7 @@ def test_upload_json_to_s3_when_error(basic_s3_client): @patch.dict(os.environ, {"BULK_IMPORT_BUCKET": "test_bucket"}) def test_upload_ingest_json_to_s3_success(basic_s3_client): + print(">>>>>>>>>>>>>>>>>>>", os.getenv("BULK_IMPORT_BUCKET", "Nothing")) json_data = {"test": "test"} upload_ingest_json_to_s3("1111-1111", "test_corpus_id", json_data) @@ -69,4 +70,4 @@ def test_do_not_save_ingest_json_to_s3_when_in_local_development(basic_s3_client ) assert "Contents" not in find_response - cleanup_local_files("1111-1111-test_corpus_id*") + cleanup_local_files("bulk_import_results/1111-1111-test_corpus_id*")