mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Add basic Asset model
This commit is contained in:
parent
e348e5e4f5
commit
34e7afbdf5
@ -378,6 +378,48 @@ def test_invalid_fulfillment_initialization(user_ffill, user_pub):
|
|||||||
Fulfillment(user_ffill, [], tx_input='somethingthatiswrong')
|
Fulfillment(user_ffill, [], tx_input='somethingthatiswrong')
|
||||||
|
|
||||||
|
|
||||||
|
def test_asset_invalid_asset_initialization():
|
||||||
|
from bigchaindb_common.transaction import Asset
|
||||||
|
|
||||||
|
with raises(TypeError):
|
||||||
|
Asset(data='some wrong type')
|
||||||
|
|
||||||
|
|
||||||
|
def test_invalid_asset_comparison(data, data_id):
|
||||||
|
from bigchaindb_common.transaction import Asset
|
||||||
|
|
||||||
|
assert Asset(data, data_id) != 'invalid comparison'
|
||||||
|
|
||||||
|
|
||||||
|
def test_asset_serialization(data, data_id):
|
||||||
|
from bigchaindb_common.transaction import Asset
|
||||||
|
|
||||||
|
expected = {
|
||||||
|
'id': data_id,
|
||||||
|
'divisible': False,
|
||||||
|
'updatable': False,
|
||||||
|
'refillable': False,
|
||||||
|
'data': data,
|
||||||
|
}
|
||||||
|
asset = Asset(data, data_id)
|
||||||
|
assert asset.to_dict() == expected
|
||||||
|
|
||||||
|
|
||||||
|
def test_asset_deserialization(data, data_id):
|
||||||
|
from bigchaindb_common.transaction import Asset
|
||||||
|
|
||||||
|
asset_dict = {
|
||||||
|
'id': data_id,
|
||||||
|
'divisible': False,
|
||||||
|
'updatable': False,
|
||||||
|
'refillable': False,
|
||||||
|
'data': data,
|
||||||
|
}
|
||||||
|
asset = Asset.from_dict(asset_dict)
|
||||||
|
expected = Asset(data, data_id)
|
||||||
|
assert asset == expected
|
||||||
|
|
||||||
|
|
||||||
def test_invalid_metadata_initialization():
|
def test_invalid_metadata_initialization():
|
||||||
from bigchaindb_common.transaction import Metadata
|
from bigchaindb_common.transaction import Metadata
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user