mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00

* Allow AssetLinks to be used in place of Assets in the Transaction Model and enforce `Transaction.transfer()` to only take an AssetLink * Remove AssetLink's inheritance from Asset * Remove id from the Asset model * Fix get_txids_by_asset_id query for rethinkdb after removing asset's uuid Because `CREATE` transactions don't have an asset that contains an id anymore, one way to find all the transactions related to an asset is to query the database twice: once for the `CREATE` transaction and another for the `TRANSFER` transactions. * Add TODO notice for vote test utils to be fixtures * Update asset model documentation to reflect usage of transaction id * Fix outdated asset description in transaction schema
60 lines
1.2 KiB
Python
60 lines
1.2 KiB
Python
from pytest import raises
|
|
|
|
|
|
def test_asset_default_values():
|
|
from bigchaindb.common.transaction import Asset
|
|
|
|
asset = Asset()
|
|
assert asset.data is None
|
|
|
|
|
|
def test_asset_creation_with_data(data):
|
|
from bigchaindb.common.transaction import Asset
|
|
|
|
asset = Asset(data)
|
|
assert asset.data == data
|
|
|
|
|
|
def test_asset_invalid_asset_initialization():
|
|
from bigchaindb.common.transaction import Asset
|
|
|
|
# check types
|
|
with raises(TypeError):
|
|
Asset(data='some wrong type')
|
|
|
|
|
|
def test_invalid_asset_comparison(data):
|
|
from bigchaindb.common.transaction import Asset
|
|
|
|
assert Asset(data) != 'invalid comparison'
|
|
|
|
|
|
def test_asset_serialization(data):
|
|
from bigchaindb.common.transaction import Asset
|
|
|
|
expected = {
|
|
'data': data,
|
|
}
|
|
asset = Asset(data)
|
|
assert asset.to_dict() == expected
|
|
|
|
|
|
def test_asset_deserialization(data):
|
|
from bigchaindb.common.transaction import Asset
|
|
|
|
asset_dict = {
|
|
'data': data,
|
|
}
|
|
asset = Asset.from_dict(asset_dict)
|
|
expected = Asset(data)
|
|
assert asset == expected
|
|
|
|
|
|
def test_validate_asset():
|
|
from bigchaindb.common.transaction import Asset
|
|
|
|
# test amount errors
|
|
asset = Asset()
|
|
with raises(TypeError):
|
|
asset.validate_asset(amount='a')
|