diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f448d2240bb9b069dd585a44c5a57a52ae9864b7..8acf1d757cb69e0a8fac2ba7f0c08feee89162c7 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 fdf1b9094219561c042daeff8432dc13c72c2537..73385723c8ad642786a8acb93e2fa91fe03a5466 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 af422433a7d63cfc6e1ade47ae392a545d833076..8867adfec81d20f3bea050e5f38981823e179540 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 adf51a98ab90b875ce8cbd2ac07b902290a434e9..581747dae427eabf2ca72cee2af227e3d46694d2 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 0e59d2977b080ff70e659a53091afc4c22e44968..31ef00f3d6472f7e23c43c71dd8a61bd0c28e041 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')