def test_get_outputs_filtered(filter_spent, filter_unspent): from bigchaindb.common.transaction import TransactionLink from bigchaindb.lib import BigchainDB go = 'bigchaindb.fastquery.FastQuery.get_outputs_by_public_key' with patch(go) as get_outputs: get_outputs.return_value = [ TransactionLink('a', 1), TransactionLink('b', 2) ] out = BigchainDB().get_outputs_filtered('abc') get_outputs.assert_called_once_with('abc') filter_spent.assert_not_called() filter_unspent.assert_not_called() assert out == get_outputs.return_value
def test_get_outputs_filtered_only_spent(): from bigchaindb.common.transaction import TransactionLink from bigchaindb.lib import BigchainDB go = 'bigchaindb.fastquery.FastQuery.get_outputs_by_public_key' with patch(go) as get_outputs: get_outputs.return_value = [ TransactionLink('a', 1), TransactionLink('b', 2) ] fs = 'bigchaindb.fastquery.FastQuery.filter_unspent_outputs' with patch(fs) as filter_spent: filter_spent.return_value = [TransactionLink('b', 2)] out = BigchainDB().get_outputs_filtered('abc', spent=True) get_outputs.assert_called_once_with('abc') assert out == [TransactionLink('b', 2)]