diff --git a/tests/conftest.py b/tests/conftest.py index 85e4809..feadd74 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -45,3 +45,30 @@ def created_derived_right_with_mock_source(client, alice): # Sleep for a bit to let the transaction become valid sleep(3) return resp.json['right'] + + +@pytest.fixture +def transferred_derived_right(client, alice, bob, + created_derived_right_with_mock_source): + import json + from time import sleep + + payload = { + 'rightId': created_derived_right_with_mock_source['@id'], + 'rightsAssignment': { + 'action': 'loan', + }, + 'currentHolder': alice, + 'to': { + 'publicKey': bob['publicKey'], + 'privateKey': None, + } + } + + client.post(url_for('right_views.righttransferapi'), + data=json.dumps(payload), + headers={'Content-Type': 'application/json'}) + + # Sleep for a bit to let the transaction become valid + sleep(3) + return created_derived_right_with_mock_source diff --git a/tests/test_api.py b/tests/test_api.py index ae774c8..df5b024 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -171,8 +171,6 @@ def test_create_right_missing_argument_in_body(client, alice): def test_transfer_right(client, alice, bob, carly, created_derived_right_with_mock_source): - from time import sleep - payload = { 'rightId': created_derived_right_with_mock_source['@id'], 'rightsAssignment': { @@ -200,10 +198,10 @@ def test_transfer_right(client, alice, bob, carly, assert resp.status_code == 200 assert resp.json == expected - # Test re-transfer, after waiting for the first transfer to become valid - sleep(3) + +def test_retransferred_right(client, bob, carly, transferred_derived_right): retransfer_payload = { - 'rightId': created_derived_right_with_mock_source['@id'], + 'rightId': transferred_derived_right['@id'], 'rightsAssignment': { 'action': 'reloan', },