Fix equality check for AssetLinks (#825)

This commit is contained in:
Brett Sun 2016-11-16 11:21:25 +01:00 committed by GitHub
parent 786635df4a
commit eb362fd6e9
2 changed files with 11 additions and 1 deletions

View File

@ -541,7 +541,7 @@ class AssetLink(Asset):
def __eq__(self, other): def __eq__(self, other):
return isinstance(other, AssetLink) and \ return isinstance(other, AssetLink) and \
self.to_dict() == self.to_dict() self.to_dict() == other.to_dict()
@classmethod @classmethod
def from_dict(cls, link): def from_dict(cls, link):

View File

@ -516,6 +516,16 @@ def test_cast_asset_link_to_boolean():
assert bool(AssetLink(False)) is True assert bool(AssetLink(False)) is True
def test_eq_asset_link():
from bigchaindb.common.transaction import AssetLink
asset_id_1 = 'asset_1'
asset_id_2 = 'asset_2'
assert AssetLink(asset_id_1) == AssetLink(asset_id_1)
assert AssetLink(asset_id_1) != AssetLink(asset_id_2)
def test_add_fulfillment_to_tx(user_ffill): def test_add_fulfillment_to_tx(user_ffill):
from bigchaindb.common.transaction import Transaction, Asset from bigchaindb.common.transaction import Transaction, Asset