From e07f6ac7a0f0ad61d192cc05d8803c15e46bcd33 Mon Sep 17 00:00:00 2001 From: ErnestaP Date: Tue, 28 May 2024 11:39:09 +0200 Subject: [PATCH] Tests: fix --- dags/scoap3/common/utils.py | 2 +- data/iop/{aca95c.xml.zip => aca95c.zip} | Bin .../integration/iop/test_iop_dag_pull_sftp.py | 6 +++--- tests/scoap3/integration/iop/test_repo.py | 4 ++-- tests/scoap3/units/iop/test_iop_sftp.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) rename data/iop/{aca95c.xml.zip => aca95c.zip} (100%) diff --git a/dags/scoap3/common/utils.py b/dags/scoap3/common/utils.py index 6a76826..e10423e 100644 --- a/dags/scoap3/common/utils.py +++ b/dags/scoap3/common/utils.py @@ -315,7 +315,7 @@ def get_country_ISO_name(country): def upload_json_to_s3(json_record, repo): file_in_bytes = io.BytesIO(json.dumps(json_record, indent=2).encode("utf-8")) - current_date = datetime.now().date() + current_date = datetime.datetime.now().date() current_date_str = current_date.strftime("%Y-%m-%d") current_date_and_time_str = current_date.strftime("%Y-%m-%d_%H:%M:%S") doi = get_value(json_record, "dois.value[0]") diff --git a/data/iop/aca95c.xml.zip b/data/iop/aca95c.zip similarity index 100% rename from data/iop/aca95c.xml.zip rename to data/iop/aca95c.zip diff --git a/tests/scoap3/integration/iop/test_iop_dag_pull_sftp.py b/tests/scoap3/integration/iop/test_iop_dag_pull_sftp.py index e4e082b..5b330be 100644 --- a/tests/scoap3/integration/iop/test_iop_dag_pull_sftp.py +++ b/tests/scoap3/integration/iop/test_iop_dag_pull_sftp.py @@ -76,7 +76,7 @@ def test_dag_run(dag, iop_empty_repo): "pdf": "extracted/2022-09-24T03_01_43_content/1674-1137/1674-1137_46/1674-1137_46_10/1674-1137_46_10_103108/cpc_46_10_103108.pdf", "xml": "extracted/2022-09-24T03_01_43_content/1674-1137/1674-1137_46/1674-1137_46_10/1674-1137_46_10_103108/cpc_46_10_103108.xml", }, - {"xml": "extracted/aca95c.xml/aca95c.xml"}, + {"xml": "extracted/aca95c/aca95c.xml"}, ] assert sorted(iop_empty_repo.find_all(), key=lambda x: x.get("xml", "")) == sorted( @@ -90,7 +90,7 @@ def test_dag_migrate_from_FTP(iop_empty_repo): migrate_from_ftp( sftp, iop_empty_repo, - get_logger().bind(class_name="test_logge"), + get_logger().bind(class_name="test_logger"), **{ "params": { "excluded_directories": [], @@ -149,7 +149,7 @@ def test_dag_migrate_from_FTP(iop_empty_repo): "pdf": "extracted/2022-09-24T03_01_43_content/1674-1137/1674-1137_46/1674-1137_46_10/1674-1137_46_10_103108/cpc_46_10_103108.pdf", "xml": "extracted/2022-09-24T03_01_43_content/1674-1137/1674-1137_46/1674-1137_46_10/1674-1137_46_10_103108/cpc_46_10_103108.xml", }, - {"xml": "extracted/aca95c.xml/aca95c.xml"}, + {"xml": "extracted/aca95c/aca95c.xml"}, ] for (file_from_repo, expected_file) in zip( iop_empty_repo.find_all(), expected_files diff --git a/tests/scoap3/integration/iop/test_repo.py b/tests/scoap3/integration/iop/test_repo.py index e5a4b89..df7ab03 100644 --- a/tests/scoap3/integration/iop/test_repo.py +++ b/tests/scoap3/integration/iop/test_repo.py @@ -75,7 +75,7 @@ def test_pull_from_sftp(iop_empty_repo): "pdf": "extracted/2022-09-24T03_01_43_content/1674-1137/1674-1137_46/1674-1137_46_10/1674-1137_46_10_103108/cpc_46_10_103108.pdf", "xml": "extracted/2022-09-24T03_01_43_content/1674-1137/1674-1137_46/1674-1137_46_10/1674-1137_46_10_103108/cpc_46_10_103108.xml", }, - {"xml": "extracted/aca95c.xml/aca95c.xml"}, + {"xml": "extracted/aca95c/aca95c.xml"}, ] assert iop_empty_repo.find_all() == expected_files assert sorted(iop_empty_repo.get_all_raw_filenames()) == sorted( @@ -84,6 +84,6 @@ def test_pull_from_sftp(iop_empty_repo): "2022-09-01T03_01_40_content.zip", "2022-09-03T03_01_49_content.zip", "2022-09-24T03_01_43_content.zip", - "aca95c.xml.zip", + "aca95c.zip", ] ) diff --git a/tests/scoap3/units/iop/test_iop_sftp.py b/tests/scoap3/units/iop/test_iop_sftp.py index deb44ba..b10c5ef 100644 --- a/tests/scoap3/units/iop/test_iop_sftp.py +++ b/tests/scoap3/units/iop/test_iop_sftp.py @@ -10,6 +10,6 @@ def test_iop_sftp_path(): "2022-09-01T03_01_40_content.zip", "2022-09-03T03_01_49_content.zip", "2022-09-24T03_01_43_content.zip", - "aca95c.xml.zip", + "aca95c.zip", ] )