From 2a47d15564f97d1a8caef2bffdb8c57f782bb533 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com>
Date: Mon, 20 Feb 2023 21:54:30 +0100
Subject: [PATCH] FIX: simple use case int test

---
 CHANGELOG.md                                                  | 1 +
 .../test_data/extroot/use_case_simple_presentation/cfood.yml  | 4 ++--
 integrationtests/test_use_case_simple_presentation.py         | 2 +-
 src/caoscrawler/crawl.py                                      | 3 ++-
 4 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3432054f..c611b771 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 - the restricted_path argument allows to crawl only a subtree
 - You can now access the file system path of a structure element (if it has one) using the variable
   name "<converter name>\_path"
+- added the arguments 'add-prefix' and 'remove-prefix' to the command line and `crawler_main`
 
 ### Changed ###
 
diff --git a/integrationtests/test_data/extroot/use_case_simple_presentation/cfood.yml b/integrationtests/test_data/extroot/use_case_simple_presentation/cfood.yml
index da3c2dfe..3cf6124d 100644
--- a/integrationtests/test_data/extroot/use_case_simple_presentation/cfood.yml
+++ b/integrationtests/test_data/extroot/use_case_simple_presentation/cfood.yml
@@ -68,8 +68,8 @@ extroot:
               parents:
                 - mdfile
               role: File
-              path: $DataFile
-              file: $DataFile
+              path: $DataFile_path
+              file: $DataFile_path
 
             Experiment: {}
 
diff --git a/integrationtests/test_use_case_simple_presentation.py b/integrationtests/test_use_case_simple_presentation.py
index ff2f2a43..4b006bd6 100644
--- a/integrationtests/test_use_case_simple_presentation.py
+++ b/integrationtests/test_use_case_simple_presentation.py
@@ -63,7 +63,7 @@ def test_complete_crawler(
                  True,
                  os.path.join(DATADIR, "provenance.yml"),
                  False,
-                 remove_prefix="/use_case_simple_presentation")
+                 remove_prefix=os.path.abspath(DATADIR))
 
     res = db.execute_query("FIND Record Experiment")
     assert len(res) == 1
diff --git a/src/caoscrawler/crawl.py b/src/caoscrawler/crawl.py
index 60face17..89291610 100644
--- a/src/caoscrawler/crawl.py
+++ b/src/caoscrawler/crawl.py
@@ -1308,7 +1308,8 @@ def crawler_main(crawled_directory_path: str,
                         elem.path = elem.path[len(remove_prefix):]
                     else:
                         raise RuntimeError("Prefix shall be removed from file path but the path "
-                                           "does not start with the prefix")
+                                           "does not start with the prefix:"
+                                           f"\n{remove_prefix}\n{elem.path}")
                 if add_prefix:
                     elem.path = add_prefix + elem.path
                 elem.file = None
-- 
GitLab