Skip to content

Commit

Permalink
Fix tests to comply with pycoalaip's stricter derived_right() sanit…
Browse files Browse the repository at this point in the history
…y checking
  • Loading branch information
sohkai committed Feb 17, 2017
1 parent d904cbe commit 6951455
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
26 changes: 26 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 5 additions & 2 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit 6951455

Please sign in to comment.