From 75a824c0fd5697f7748f57f09e022bce97d32e0c Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 7 May 2019 18:16:46 -0700 Subject: test basic entity revision GET --- python/tests/api_containers.py | 14 ++++++++------ python/tests/api_creators.py | 16 ++++++++++------ python/tests/api_files.py | 18 ++++++++++++++---- python/tests/api_filesets.py | 5 +++++ python/tests/api_releases.py | 6 ++++++ python/tests/api_webcaptures.py | 6 ++++++ 6 files changed, 49 insertions(+), 16 deletions(-) diff --git a/python/tests/api_containers.py b/python/tests/api_containers.py index 674ae3b8..ad6d03be 100644 --- a/python/tests/api_containers.py +++ b/python/tests/api_containers.py @@ -33,16 +33,18 @@ def test_container(api): assert c1.wikidata_qid == c2.wikidata_qid assert c1.extra == c2.extra - # expansion - # TODO: via release - # lookup - # TODO: via issnl; but need to generate random identifiers + # get revision + c2_rev = api.get_container_revision(c1edit.revision) + assert c1edit.revision == c2_rev.revision + assert c2.revision == c2_rev.revision + assert c2.name == c2_rev.name def test_container_examples(api): - api.lookup_container(issnl='1549-1277') - c1 = api.get_container('aaaaaaaaaaaaaeiraaaaaaaaam') assert c1.name == "PLOS Medicine" assert c1.issnl == "1549-1277" + c2 = api.lookup_container(issnl=c1.issnl) + assert c1.ident == c2.ident + diff --git a/python/tests/api_creators.py b/python/tests/api_creators.py index 7443675b..82067b3f 100644 --- a/python/tests/api_creators.py +++ b/python/tests/api_creators.py @@ -33,12 +33,16 @@ def test_creators(api): assert c1.wikidata_qid == c2.wikidata_qid assert c1.extra == c2.extra - # expansion - # TODO: via release - # lookup - # TODO: via issnl; but need to generate random identifiers + # get revision + c2_rev = api.get_creator_revision(c1edit.revision) + assert c1edit.revision == c2_rev.revision + assert c2.revision == c2_rev.revision + assert c2.display_name == c2_rev.display_name + +# TODO: test expansion of new creator/release pair (release get)? def test_creators_examples(api): - # TODO: aaaaaaaaaaaaaircaaaaaaaaam + # ident: aaaaaaaaaaaaaircaaaaaaaaam - api.lookup_creator(orcid='0000-0003-3118-6859') + c1 = api.lookup_creator(orcid='0000-0003-3118-6859') + assert c1.ident == "aaaaaaaaaaaaaircaaaaaaaaam" diff --git a/python/tests/api_files.py b/python/tests/api_files.py index 033538ef..41318e25 100644 --- a/python/tests/api_files.py +++ b/python/tests/api_files.py @@ -40,13 +40,23 @@ def test_file(api): assert f1.urls == f2.urls assert f1.release_ids == f2.release_ids - # expansion - # TODO: via release - # lookup - # TODO: via hashes; but need to generate random? + # get revision + f2_rev = api.get_file_revision(f1edit.revision) + assert f1edit.revision == f2_rev.revision + assert f2.revision == f2_rev.revision def test_file_examples(api): api.lookup_file(sha256='ffc1005680cb620eec4c913437dfabbf311b535cfe16cbaeb2faec1f92afc362') f1 = api.get_file('aaaaaaaaaaaaamztaaaaaaaaam') + assert f1.sha256 == "ffc1005680cb620eec4c913437dfabbf311b535cfe16cbaeb2faec1f92afc362" + + # TODO: no "get_file_releases" or expand thing yet... + #f1r = api.get_file_releases("aaaaaaaaaaaaamztaaaaaaaaam") + #assert f1r + + # expansion (back from release) + #r1 = api.get_release(f1r[0].ident, expand="files") + #assert r1.files + #assert f1.ident in [f.ident for f in r1.files] diff --git a/python/tests/api_filesets.py b/python/tests/api_filesets.py index 966b85ca..6f3305c1 100644 --- a/python/tests/api_filesets.py +++ b/python/tests/api_filesets.py @@ -44,6 +44,11 @@ def test_fileset(api): api.accept_editgroup(eg.editgroup_id) fs2 = api.get_fileset(fs1edit.ident) + # get revision + fs2_rev = api.get_fileset_revision(fs1edit.revision) + assert fs1edit.revision == fs2_rev.revision + assert fs2.revision == fs2_rev.revision + # check that fields match assert fs1.urls == fs2.urls assert fs1.manifest == fs2.manifest diff --git a/python/tests/api_releases.py b/python/tests/api_releases.py index a52abfb5..f495777c 100644 --- a/python/tests/api_releases.py +++ b/python/tests/api_releases.py @@ -54,6 +54,12 @@ def test_release(api): api.accept_editgroup(eg.editgroup_id) r2 = api.get_release(r1edit.ident) + # get revision + r2_rev = api.get_release_revision(r1edit.revision) + assert r1edit.revision == r2_rev.revision + assert r2.revision == r2_rev.revision + assert r2.title == r2_rev.title + # check that fields match assert r1.title == r2.title assert r1.original_title == r2.original_title diff --git a/python/tests/api_webcaptures.py b/python/tests/api_webcaptures.py index dc1754b3..db3ef172 100644 --- a/python/tests/api_webcaptures.py +++ b/python/tests/api_webcaptures.py @@ -51,6 +51,12 @@ def test_webcapture(api): api.accept_editgroup(eg.editgroup_id) wc2 = api.get_webcapture(wc1edit.ident) + # get revision + wc2_rev = api.get_webcapture_revision(wc1edit.revision) + assert wc1edit.revision == wc2_rev.revision + assert wc2.revision == wc2_rev.revision + assert wc2.timestamp == wc2_rev.timestamp + # check that fields match # I don't know why these aren't equal... #print(wc1.archive_urls) -- cgit v1.2.3