Commit 74842a3a authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Fixed wrong fairdi calc files after publish to coe in coe mode.

parent b3ac9757
Pipeline #51400 passed with stages
in 17 minutes and 20 seconds
......@@ -538,6 +538,7 @@ class Upload(Proc):
with utils.lnr(logger, '(re-)publish failed'):
upload_with_metadata = self.to_upload_with_metadata(self.metadata)
calcs = upload_with_metadata.calcs
if config.repository_db.publish_enabled:
if config.repository_db.mode == 'coe' and isinstance(self.upload_files, StagingUploadFiles):
......@@ -555,13 +556,10 @@ class Upload(Proc):
coe_upload = coe_repo.Upload.publish(upload_with_metadata)
with utils.timer(
logger, 'upload read from repository', step='repo',
logger, 'upload PIDs read from repository', step='repo',
upload_size=self.upload_files.size):
calcs = [
coe_calc.to_calc_with_metadata()
for coe_calc in coe_upload.calcs]
else:
calcs = upload_with_metadata.calcs
for calc, coe_calc in zip(calcs, coe_upload.calcs):
calc.pid = coe_calc.coe_calc_id
with utils.timer(
logger, 'upload metadata updated', step='metadata',
......
......@@ -64,7 +64,7 @@ def run_processing(uploaded: Tuple[str, str], test_user) -> Upload:
return upload
def assert_processing(upload: Upload):
def assert_processing(upload: Upload, published: bool = False):
assert not upload.tasks_running
assert upload.current_task == 'cleanup'
assert upload.upload_id is not None
......@@ -72,25 +72,33 @@ def assert_processing(upload: Upload):
assert upload.tasks_status == SUCCESS
upload_files = UploadFiles.get(upload.upload_id, is_authorized=lambda: True)
assert isinstance(upload_files, StagingUploadFiles)
if published:
assert isinstance(upload_files, PublicUploadFiles)
else:
assert isinstance(upload_files, StagingUploadFiles)
for calc in Calc.objects(upload_id=upload.upload_id):
assert calc.parser is not None
assert calc.mainfile is not None
assert calc.tasks_status == SUCCESS
assert calc.metadata['published'] == published
with upload_files.archive_file(calc.calc_id) as archive_json:
archive = json.load(archive_json)
assert 'section_run' in archive
assert 'section_entry_info' in archive
with upload_files.archive_log_file(calc.calc_id) as f:
with upload_files.archive_log_file(calc.calc_id, 'rt') as f:
assert 'a test' in f.read()
assert len(calc.errors) == 0
with upload_files.raw_file(calc.mainfile) as f:
f.read()
for path in calc.metadata['files']:
with upload_files.raw_file(path) as f:
f.read()
assert upload.get_calc(calc.calc_id).metadata is not None
......@@ -125,6 +133,8 @@ def test_publish(non_empty_processed: Upload, no_warn, example_user_metadata, wi
if with_publish_to_coe_repo and config.repository_db.mode == 'coe':
assert(os.path.exists(os.path.join(config.fs.coe_extracted, upload.upload_id)))
assert_processing(Upload.get(upload.upload_id, include_published=True), published=True)
def test_republish(non_empty_processed: Upload, no_warn, example_user_metadata, monkeypatch, with_publish_to_coe_repo):
processed = non_empty_processed
......
......@@ -82,6 +82,9 @@ def assert_coe_calc(coe_calc: Calc, calc: datamodel.DFTCalcWithMetadata, has_han
assert len(coe_calc.files) == len(calc.files)
assert coe_calc.formula == calc.formula
# calc files
assert len(coe_calc.files) == len(calc.files)
# user meta data
assert coe_calc.comment == calc.comment
assert len(coe_calc.references) == len(calc.references)
......
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