From 3ca58793284913ac228da18a06885628795c80b1 Mon Sep 17 00:00:00 2001 From: Thomas Thelen Date: Fri, 18 Sep 2020 22:07:23 -0700 Subject: [PATCH] Fix tests --- .../lib/dataone/test_dataone_metadata.py | 2 +- gwvolman/tests/lib/test_publish_provider.py | 32 ++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/gwvolman/tests/lib/dataone/test_dataone_metadata.py b/gwvolman/tests/lib/dataone/test_dataone_metadata.py index d0e7e0fe..a7c40145 100644 --- a/gwvolman/tests/lib/dataone/test_dataone_metadata.py +++ b/gwvolman/tests/lib/dataone/test_dataone_metadata.py @@ -108,4 +108,4 @@ def test_generate_system_metadata(): assert sys_meta.rightsHolder.value() == rights_holder assert sys_meta.checksum.value() == dataoneTypes.checksum(md5).value() assert sys_meta.checksum.algorithm == 'MD5' - assert sys_meta.fileName.value() == name + assert sys_meta.fileName == name diff --git a/gwvolman/tests/lib/test_publish_provider.py b/gwvolman/tests/lib/test_publish_provider.py index 04df79b9..8071d5e1 100644 --- a/gwvolman/tests/lib/test_publish_provider.py +++ b/gwvolman/tests/lib/test_publish_provider.py @@ -265,4 +265,34 @@ def test_publication_info(): mock_gc.sendRestRequest.return_value = mock_req provider = PublishProvider(mock_gc, PUBLISHED_TALE['_id'], TOKEN) - assert provider.publication_info is True \ No newline at end of file + assert provider.publication_info is True + + +def test_access_token(): + mock_gc = mock.MagicMock(spec=GirderClient) + mock_req = mock.MagicMock() + mock_gc.get = mock_gc_get + mock_gc.sendRestRequest.return_value = mock_req + + provider = PublishProvider(mock_gc, PUBLISHED_TALE['_id'], TOKEN) + assert provider.access_token == TOKEN['access_token'] + + +def test_resource_server_token(): + mock_gc = mock.MagicMock(spec=GirderClient) + mock_req = mock.MagicMock() + mock_gc.get = mock_gc_get + mock_gc.sendRestRequest.return_value = mock_req + + provider = PublishProvider(mock_gc, PUBLISHED_TALE['_id'], TOKEN) + assert provider.access_token == TOKEN['resource_server'] + + +def test_publish(): + with pytest.raises(NotImplementedError): + mock_gc = mock.MagicMock(spec=GirderClient) + mock_req = mock.MagicMock() + mock_gc.get = mock_gc_get + mock_gc.sendRestRequest.return_value = mock_req + provider = PublishProvider(mock_gc, PUBLISHED_TALE['_id'], TOKEN) + provider.publish()