Skip to content

Commit

Permalink
Add tests for update_sysmeta
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasThelen committed Sep 23, 2020
1 parent f60f6d4 commit 28f6a50
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions gwvolman/tests/lib/dataone/test_dataone_publish.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import copy
import girder_worker
from girder_client import GirderClient
from hashlib import md5
import httmock
from io import BytesIO
import mock
import os
import jwt
import pytest
import uuid
from d1_common.system_metadata import generate_system_metadata_pyxb

from gwvolman.lib.publish_provider import NullManager
from gwvolman.tasks import publish
Expand Down Expand Up @@ -219,6 +222,23 @@ def test_get_manifest_file_info():
assert md5 is None


def test_update_sysmeta():
original_sysmeta = generate_system_metadata_pyxb("pid",
"format_id",
BytesIO(b"body"),
"submitter",
"rights_holder",
"urn:mn:urn",)
new_data = "98765"
new_pid = "1234"
new_checksum = md5(new_data.encode("utf-8")).hexdigest()
new_sysmeta = DataONEPublishProvider.update_sysmeta(original_sysmeta, new_data, new_pid)
assert new_sysmeta.size
assert new_sysmeta.identifier.value() == new_pid
assert new_sysmeta.obsoletes is None
assert new_sysmeta.checksum.value() == new_checksum


@pytest.mark.celery(result_backend="rpc")
def test_dataone_publish():
mock_gc = mock.MagicMock(spec=GirderClient)
Expand Down

0 comments on commit 28f6a50

Please # to comment.