From c3c18436a370e5b106af31313047f50b07456ea4 Mon Sep 17 00:00:00 2001
From: Markus Scheidgen <markus.scheidgen@gmail.com>
Date: Thu, 6 Dec 2018 14:27:27 +0100
Subject: [PATCH] Removed rawapi tests.

---
 .gitlab-ci.yml    | 9 ---------
 nomad/api/raw.py  | 8 +++++---
 nomad/files.py    | 4 ++++
 rawapi.Dockerfile | 2 --
 tests/conftest.py | 4 +---
 5 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index f448d2240b..8acf1d757c 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -100,15 +100,6 @@ tests:
   except:
     - /^dev-.*$/
 
-rawapi_tests:
-  stage: test
-  image: $RAWAPI_TEST_IMAGE
-  script:
-    - cd /app
-    - python -m pytest -sv tests/test_api.py::TestRaw
-  except:
-    - /^dev-.*$/
-
 # does currently not work, current GitLab CI runner does not network services with each other
 # integration-tests:
 #   stage: integration
diff --git a/nomad/api/raw.py b/nomad/api/raw.py
index fdf1b90942..73385723c8 100644
--- a/nomad/api/raw.py
+++ b/nomad/api/raw.py
@@ -68,9 +68,11 @@ def get_raw_file(upload_hash, upload_filepath):
                 attachment_filename=os.path.basename(upload_filepath))
             return rv
     except KeyError:
-        abort(404, message='The file %s does not exist.' % upload_filepath)
-    except FileNotFoundError:
-        abort(404, message='The file %s does not exist.' % upload_filepath)
+        files = list(file for file in repository_file.manifest if file.startswith(upload_filepath))
+        if len(files) == 0:
+            abort(404, message='The file %s does not exist.' % upload_filepath)
+        else:
+            abort(404, message='The file %s does not exist, but there are files with matching paths' % upload_filepath, files=files)
     except HTTPException as e:
         raise e
     except Exception as e:
diff --git a/nomad/files.py b/nomad/files.py
index af422433a7..8867adfec8 100644
--- a/nomad/files.py
+++ b/nomad/files.py
@@ -414,6 +414,10 @@ class RepositoryFile(ObjectFile):
     def get_file(self, path: str) -> ZippedFile:
         return self._zipped_container.get_file(path)
 
+    @property
+    def manifest(self) -> List[str]:
+        return self._zipped_container.manifest
+
 
 class ArchiveFile(ObjectFile):
     """
diff --git a/rawapi.Dockerfile b/rawapi.Dockerfile
index adf51a98ab..581747dae4 100644
--- a/rawapi.Dockerfile
+++ b/rawapi.Dockerfile
@@ -26,8 +26,6 @@ WORKDIR /install
 RUN pip install --upgrade pip
 COPY requirements.txt requirements.txt
 RUN pip install -r requirements.txt
-RUN pip install pytest
-RUN pip install pytest-timeout
 
 # do that after the dependencies to use docker's layer caching
 COPY . /install
diff --git a/tests/conftest.py b/tests/conftest.py
index 0e59d2977b..31ef00f3d6 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -4,7 +4,7 @@ from sqlalchemy.orm import Session
 from mongoengine import connect
 from mongoengine.connection import disconnect
 
-from nomad import config, infrastructure
+from nomad import config, infrastructure, coe_repo
 
 
 @pytest.fixture(scope="session")
@@ -119,13 +119,11 @@ def repository_db(monkeysession):
 
 @pytest.fixture(scope='session')
 def test_user(repository_db):
-    from nomad import coe_repo
     return coe_repo.ensure_test_user(email='sheldon.cooper@nomad-fairdi.tests.de')
 
 
 @pytest.fixture(scope='session')
 def other_test_user(repository_db):
-    from nomad import coe_repo
     return coe_repo.ensure_test_user(email='leonard.hofstadter@nomad-fairdi.tests.de')
 
 
-- 
GitLab