mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Add to_uri for TransactionLink
This commit is contained in:
parent
d8256d50f2
commit
f78c90ada8
@ -189,6 +189,12 @@ class TransactionLink(object):
|
||||
'cid': self.cid,
|
||||
}
|
||||
|
||||
def to_uri(self, path=''):
|
||||
if self.txid is None and self.cid is None:
|
||||
return None
|
||||
return '{}/transactions/{}/conditions/{}'.format(path, self.txid,
|
||||
self.cid)
|
||||
|
||||
|
||||
class Condition(object):
|
||||
"""A Condition is used to lock an asset.
|
||||
|
@ -428,6 +428,24 @@ def test_transaction_link_deserialization_with_empty_payload():
|
||||
assert tx_link == expected
|
||||
|
||||
|
||||
def test_transaction_link_empty_to_uri():
|
||||
from bigchaindb.common.transaction import TransactionLink
|
||||
|
||||
expected = None
|
||||
tx_link = TransactionLink().to_uri()
|
||||
|
||||
assert expected == tx_link
|
||||
|
||||
|
||||
def test_transaction_link_to_uri():
|
||||
from bigchaindb.common.transaction import TransactionLink
|
||||
|
||||
expected = 'path/transactions/abc/conditions/0'
|
||||
tx_link = TransactionLink('abc', 0).to_uri('path')
|
||||
|
||||
assert expected == tx_link
|
||||
|
||||
|
||||
def test_cast_transaction_link_to_boolean():
|
||||
from bigchaindb.common.transaction import TransactionLink
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user