Commit aa120658 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Fixed raw all endpoint test. Added client reproduction skeleton.

parent d028b9ed
Pipeline #37670 passed with stages
in 7 minutes and 34 seconds
......@@ -23,7 +23,6 @@ import os.path
import zipstream
from zipfile import ZIP_DEFLATED
from contextlib import contextmanager
import types
from nomad import config, infrastructure
from nomad.files import UploadFile, ArchiveFile, ArchiveLogFile
......@@ -135,7 +135,7 @@ class CalcProcReproduction(UploadFile):
an fake 'upload' that only contains the respective calculation data. This allows us
to locally run processing code that is very similar to the one used on the server.
def __init__(self, archive_id: str) -> CalcProcReproduction:
def __init__(self, archive_id: str) -> None:
local_path = os.path.join(config.fs.tmp, '' % archive_id)
if not os.path.exists(local_path):
# download raw if not already downloaded
......@@ -146,20 +146,20 @@ class CalcProcReproduction(UploadFile):
super().__init__(upload_id='tmp_%s' % archive_id, local_path=local_path)
def parse(parser_name: str = None):
def parse(self, parser_name: str = None):
Run the given parser on the downloaded calculation. If no parser is given,
do parser matching and use the respective parser.
def normalize(normalizer_name: str):
def normalize(self, normalizer_name: str):
Parse the downloaded calculation and run the given normalizer.
def normalize_all():
def normalize_all(self):
Parse the downloaded calculation and run the whole normalizer chain.
......@@ -8,6 +8,8 @@ from mongoengine import connect
from mongoengine.connection import disconnect
from datetime import datetime, timedelta
import base64
import zipfile
import io
from nomad import config
# for convinience we test the api without path prefix
......@@ -356,8 +358,9 @@ def test_raw_all_files(client, example_repo_with_files, no_warn):
rv = client.get('/raw/%s?all=1' % example_repo_with_files.archive_id)
assert rv.status_code == 200
assert len( > 0
with open('', 'wb') as f:
with zipfile.ZipFile(io.BytesIO( as zip_file:
assert zip_file.testzip() is None
assert len(zip_file.namelist()) == 5
def test_raw_missing_mainfile(client, no_warn):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment