Skip to content

Commit

Permalink
Move retransfer test to its own separate test and add fixture for it
Browse files Browse the repository at this point in the history
  • Loading branch information
sohkai committed Feb 10, 2017
1 parent 5be8368 commit d457193
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
27 changes: 27 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 3 additions & 5 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand Down Expand Up @@ -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',
},
Expand Down

0 comments on commit d457193

Please sign in to comment.