From 69514559da5623ee8f988c9ca97ef47b4c4aee40 Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Fri, 17 Feb 2017 21:01:11 +0100 Subject: [PATCH] Fix tests to comply with pycoalaip's stricter `derived_right()` sanity checking --- README.md | 4 ++-- tests/conftest.py | 26 ++++++++++++++++++++++++++ tests/test_api.py | 7 +++++-- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1a4c04e..6195cce 100644 --- a/README.md +++ b/README.md @@ -263,8 +263,8 @@ part of the new Right's chain of provenance. Note that the attributes for the `right` may be much more diverse; see its [COALA IP models definition](https://github.com/COALAIP/specs/tree/master/data-structure#rrm-right). -Also see transferring a Right on how to transfer a registered Right to new -holders. +Also see [transferring a Right](#transfer-a-right) on how to transfer a +registered Right to new holders. ``` POST /api/v1/rights/ diff --git a/tests/conftest.py b/tests/conftest.py index ea554f7..308da7e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -13,3 +13,29 @@ def app(): @pytest.fixture def user(client): return client.post(url_for('user_views.userapi')).json + + +@pytest.fixture +def created_manifestation_resp(client, user): + import json + from time import sleep + payload = { + 'manifestation': { + 'name': 'The Fellowship of the Ring', + 'datePublished': '29-07-1954', + 'url': 'http://localhost/lordoftherings.txt', + }, + 'copyrightHolder': alice, + 'work': { + 'name': 'The Lord of the Rings Triology', + 'author': 'J. R. R. Tolkien', + }, + } + + resp = client.post(url_for('manifestation_views.manifestationapi'), + data=json.dumps(payload), + headers={'Content-Type': 'application/json'}) + + # Sleep for a bit to let the transaction become valid + sleep(3) + return resp.json diff --git a/tests/test_api.py b/tests/test_api.py index 14a1674..beec3d6 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -108,13 +108,16 @@ def test_create_manifestation_missing_argument_in_body(client): 'Missing required parameter in the JSON body' -def test_create_right(client, user): +def test_create_right(client, user, created_manifestation_resp): + copyright_id = created_manifestation_resp['copyright']['@id'] + copyright_id = copyright_id.split('../rights/')[1] + payload = { 'currentHolder': user, 'right': { 'license': 'http://www.ascribe.io/terms', }, - 'sourceRightId': 'mockId', + 'sourceRightId': copyright_id, } expected = {