From f010293627841e54d2e87c278f3c3d5929714b1e Mon Sep 17 00:00:00 2001 From: Mark Jordan Date: Mon, 14 Aug 2023 21:07:10 -0700 Subject: [PATCH] WIP on #487. --- .../assets/create_from_files_test/create.yml | 7 ++-- .../assets/create_from_files_test/delete.yml | 5 +-- tests/assets/create_test/create.yml | 4 +-- tests/assets/create_test/delete.yml | 4 +-- tests/assets/create_test/metadata.csv | 10 +++--- tests/assets/delete_test/create.yml | 4 +-- tests/assets/delete_test/delete.yml | 4 +-- tests/assets/delete_test/metadata.csv | 10 +++--- tests/assets/non_latin_text_test/create.yml | 4 +-- tests/assets/non_latin_text_test/delete.yml | 4 +-- tests/assets/non_latin_text_test/metadata.csv | 6 ++-- tests/assets/update_test/create.yml | 4 +-- tests/assets/update_test/delete.yml | 4 +-- tests/assets/update_test/update.yml | 4 +-- tests/islandora_tests.py | 35 ++++++++++++++----- 15 files changed, 65 insertions(+), 44 deletions(-) diff --git a/tests/assets/create_from_files_test/create.yml b/tests/assets/create_from_files_test/create.yml index e99f97e8..5b7ac549 100644 --- a/tests/assets/create_from_files_test/create.yml +++ b/tests/assets/create_from_files_test/create.yml @@ -1,7 +1,7 @@ task: create_from_files -host: "http://localhost:8000" +host: https://islandora.traefik.me username: admin -password: islandora +password: password input_dir: tests/assets/create_from_files_test/files models: - 'http://purl.org/coar/resource_type/c_1843': ['zip', 'tar', ''] @@ -9,4 +9,5 @@ models: - 'http://purl.org/coar/resource_type/c_c513': ['tif', 'tiff', 'jp2', 'png', 'gif', 'jpg', 'jpeg'] - 'http://purl.org/coar/resource_type/c_18cc': ['mp3', 'wav', 'aac'] - 'http://purl.org/coar/resource_type/c_12ce': ['mp4'] -log_json: true +# log_json: true +standalone_media_url: true diff --git a/tests/assets/create_from_files_test/delete.yml b/tests/assets/create_from_files_test/delete.yml index 2db263cd..d5b16e02 100644 --- a/tests/assets/create_from_files_test/delete.yml +++ b/tests/assets/create_from_files_test/delete.yml @@ -1,6 +1,7 @@ task: delete -host: "http://localhost:8000" +host: https://islandora.traefik.me username: admin -password: islandora +password: password input_dir: "tests/assets/create_from_files_test" input_csv: /tmp/workbenchcreatefromfilestestnids.txt +standalone_media_url: true diff --git a/tests/assets/create_test/create.yml b/tests/assets/create_test/create.yml index 3c2980c8..8eb89ca4 100644 --- a/tests/assets/create_test/create.yml +++ b/tests/assets/create_test/create.yml @@ -1,7 +1,7 @@ task: create -host: "http://localhost:8000" +host: https://islandora.traefik.me username: admin -password: islandora +password: password input_dir: "tests/assets/create_test" media_type: image allow_missing_files: True diff --git a/tests/assets/create_test/delete.yml b/tests/assets/create_test/delete.yml index 55dbc74e..994d8444 100644 --- a/tests/assets/create_test/delete.yml +++ b/tests/assets/create_test/delete.yml @@ -1,6 +1,6 @@ task: delete -host: "http://localhost:8000" +host: https://islandora.traefik.me username: admin -password: islandora +password: password input_dir: "tests/assets/create_test" input_csv: /tmp/workbenchcreatetestnids.txt diff --git a/tests/assets/create_test/metadata.csv b/tests/assets/create_test/metadata.csv index b39d1de6..3660ada2 100644 --- a/tests/assets/create_test/metadata.csv +++ b/tests/assets/create_test/metadata.csv @@ -1,6 +1,6 @@ file,title,id,field_model,field_description -,Small boats in Havana Harbour,01,24,Taken on vacation in Cuba. -,Manhatten Island,02,24,"Taken from the ferry from downtown New York to Highlands, NJ. Weather was windy." -,Looking across Burrard Inlet,03,24,View from Deep Cove to Burnaby Mountain. Simon Fraser University is visible on the top of the mountain in the distance. -,Amsterdam waterfront,04,24,Amsterdam waterfront on an overcast day. -,Alcatraz Island,05,24,"Taken from Fisherman's Wharf, San Francisco." +,Small boats in Havana Harbour,01,Image,Taken on vacation in Cuba. +,Manhatten Island,02,Image,"Taken from the ferry from downtown New York to Highlands, NJ. Weather was windy." +,Looking across Burrard Inlet,03,Image,View from Deep Cove to Burnaby Mountain. Simon Fraser University is visible on the top of the mountain in the distance. +,Amsterdam waterfront,04,Image,Amsterdam waterfront on an overcast day. +,Alcatraz Island,05,Image,"Taken from Fisherman's Wharf, San Francisco." diff --git a/tests/assets/delete_test/create.yml b/tests/assets/delete_test/create.yml index 7d41d401..2a0599de 100644 --- a/tests/assets/delete_test/create.yml +++ b/tests/assets/delete_test/create.yml @@ -1,7 +1,7 @@ task: create -host: "http://localhost:8000" +host: https://islandora.traefik.me username: admin -password: islandora +password: password input_dir: "tests/assets/delete_test" allow_missing_files: True nodes_only: true diff --git a/tests/assets/delete_test/delete.yml b/tests/assets/delete_test/delete.yml index 1cf149af..f858bbe1 100644 --- a/tests/assets/delete_test/delete.yml +++ b/tests/assets/delete_test/delete.yml @@ -1,6 +1,6 @@ task: delete -host: "http://localhost:8000" +host: https://islandora.traefik.me username: admin -password: islandora +password: password input_dir: "tests/assets/delete_test" input_csv: /tmp/workbenchdeletetesttnids.txt diff --git a/tests/assets/delete_test/metadata.csv b/tests/assets/delete_test/metadata.csv index 63434ab7..6c6a517b 100644 --- a/tests/assets/delete_test/metadata.csv +++ b/tests/assets/delete_test/metadata.csv @@ -1,6 +1,6 @@ file,id,title,field_model,field_description -,01,Small boats in Havana Harbour,24,Taken on vacation in Cuba. -,02,Manhatten Island,24,"Taken from the ferry from downtown New York to Highlands, NJ. Weather was windy." -,03,Looking across Burrard Inlet,24,View from Deep Cove to Burnaby Mountain. Simon Fraser University is visible on the top of the mountain in the distance. -,04,Amsterdam waterfront,24,Amsterdam waterfront on an overcast day. -,05,Alcatraz Island,24,"Taken from Fisherman's Wharf, San Francisco." +,01,Small boats in Havana Harbour,Image,Taken on vacation in Cuba. +,02,Manhatten Island,Image,"Taken from the ferry from downtown New York to Highlands, NJ. Weather was windy." +,03,Looking across Burrard Inlet,Image,View from Deep Cove to Burnaby Mountain. Simon Fraser University is visible on the top of the mountain in the distance. +,04,Amsterdam waterfront,Image,Amsterdam waterfront on an overcast day. +,05,Alcatraz Island,Image,"Taken from Fisherman's Wharf, San Francisco." diff --git a/tests/assets/non_latin_text_test/create.yml b/tests/assets/non_latin_text_test/create.yml index 9216b28b..5f5a58b9 100644 --- a/tests/assets/non_latin_text_test/create.yml +++ b/tests/assets/non_latin_text_test/create.yml @@ -1,7 +1,7 @@ task: create -host: "http://localhost:8000" +host: https://islandora.traefik.me username: admin -password: islandora +password: password input_dir: "tests/assets/non_latin_text_test" allow_missing_files: True nodes_only: true diff --git a/tests/assets/non_latin_text_test/delete.yml b/tests/assets/non_latin_text_test/delete.yml index 23874cb5..3cc12e0d 100644 --- a/tests/assets/non_latin_text_test/delete.yml +++ b/tests/assets/non_latin_text_test/delete.yml @@ -1,6 +1,6 @@ task: delete -host: "http://localhost:8000" +host: https://islandora.traefik.me username: admin -password: islandora +password: password input_dir: "tests/assets/non_latin_text_test" input_csv: /tmp/workbenchcreatenonlatintestnids.txt diff --git a/tests/assets/non_latin_text_test/metadata.csv b/tests/assets/non_latin_text_test/metadata.csv index 53dcc269..1afaf190 100644 --- a/tests/assets/non_latin_text_test/metadata.csv +++ b/tests/assets/non_latin_text_test/metadata.csv @@ -1,4 +1,4 @@ id,field_model,title -1,25,一九二四年六月十二日 -2,25,"सरकारी दस्तावेज़" -3,25,"ᐊᑕᐅᓯᖅ ᓄᓇ, ᐅᓄᖅᑐᑦ ᓂᐲᑦ" +1,Image,一九二四年六月十二日 +2,Image,"सरकारी दस्तावेज़" +3,Image,"ᐊᑕᐅᓯᖅ ᓄᓇ, ᐅᓄᖅᑐᑦ ᓂᐲᑦ" diff --git a/tests/assets/update_test/create.yml b/tests/assets/update_test/create.yml index 0647d276..147ffe70 100644 --- a/tests/assets/update_test/create.yml +++ b/tests/assets/update_test/create.yml @@ -1,7 +1,7 @@ task: create -host: "http://localhost:8000" +host: https://islandora.traefik.me username: admin -password: islandora +password: password input_dir: "tests/assets/update_test" input_csv: create.csv allow_missing_files: true diff --git a/tests/assets/update_test/delete.yml b/tests/assets/update_test/delete.yml index b1c4adbf..9433eb6b 100644 --- a/tests/assets/update_test/delete.yml +++ b/tests/assets/update_test/delete.yml @@ -1,6 +1,6 @@ task: delete -host: "http://localhost:8000" +host: https://islandora.traefik.me username: admin -password: islandora +password: password input_dir: "tests/assets/update_test" input_csv: /tmp/workbenchupdatetestnids.txt diff --git a/tests/assets/update_test/update.yml b/tests/assets/update_test/update.yml index 9790a304..a720c207 100644 --- a/tests/assets/update_test/update.yml +++ b/tests/assets/update_test/update.yml @@ -1,7 +1,7 @@ task: update -host: "http://localhost:8000" +host: https://islandora.traefik.me username: admin -password: islandora +password: password input_dir: "tests/assets/update_test" input_csv: workbenchupdatetest.csv validate_title_length: false diff --git a/tests/islandora_tests.py b/tests/islandora_tests.py index 18c5da63..599a914f 100644 --- a/tests/islandora_tests.py +++ b/tests/islandora_tests.py @@ -64,6 +64,12 @@ def tearDown(self): if os.path.exists(self.preprocessed_file_path): os.remove(self.preprocessed_file_path) + self.preprocessed_nid_file_path = self.nid_file + '.preprocessed' + if os.path.exists(self.nid_file): + os.remove(self.nid_file) + if os.path.exists(self.preprocessed_nid_file_path): + os.remove(self.preprocessed_nid_file_path) + class TestCreateFromFiles(unittest.TestCase): @@ -101,12 +107,17 @@ def tearDown(self): if os.path.exists(self.rollback_file_path): os.remove(self.rollback_file_path) + if os.path.exists(self.rollback_file_path): + os.remove(self.rollback_file_path) + + self.preprocessed_nid_file_path = self.nid_file + '.preprocessed' + if os.path.exists(self.preprocessed_nid_file_path): + os.remove(self.preprocessed_nid_file_path) + class TestCreateWithNewTypedRelation(unittest.TestCase): - # Note: You can't run this test class on its own, e.g., - # python3 tests/islandora_tests.py TestCreateWithNewTypedRelation. - # because passing "TestCreateWithNewTypedRelation" as an argument - # will cause the argparse parser to fail. + # Note: You can't run this test class on its own, e.g., python3 tests/islandora_tests.py TestCreateWithNewTypedRelation. + # because passing "TestCreateWithNewTypedRelation" as an argument will cause the argparse parser to fail. def setUp(self): self.current_dir = os.path.dirname(os.path.abspath(__file__)) @@ -263,13 +274,17 @@ def tearDown(self): os.remove(self.nid_file) os.remove(self.update_metadata_file) + nid_file_preprocessed_file = os.path.join(self.temp_dir, 'workbenchupdatetestnids.txt.preprocessed') + if os.path.exists(nid_file_preprocessed_file): + os.remove(nid_file_preprocessed_file) + update_test_csv_preprocessed_file = os.path.join(self.temp_dir, 'workbenchupdatetest.csv.preprocessed') + if os.path.exists(update_test_csv_preprocessed_file): + os.remove(update_test_csv_preprocessed_file) class TestTermFromUri(unittest.TestCase): - # Note: You can't run this test class on its own, e.g., - # python3 tests/islandora_tests.py TestTermFromUri. - # because passing "TestTermFromUri" as an argument - # will cause the argparse parser to fail. + # Note: You can't run this test class on its own, e.g., python3 tests/islandora_tests.py TestTermFromUri + # because passing "TestTermFromUri" as an argument will cause the argparse parser to fail. def test_term_from_uri(self): current_dir = os.path.dirname(os.path.abspath(__file__)) @@ -357,6 +372,10 @@ def tearDown(self): if os.path.exists(preprocessed_csv_path): os.remove(preprocessed_csv_path) + nid_file_preprocessed_path = self.nid_file + '.preprocessed' + if os.path.exists(nid_file_preprocessed_path): + os.remove(nid_file_preprocessed_path) + class TestSecondaryTask(unittest.TestCase):