def test_wrong_asset_type(instrument_constructor): '''Try to transfer eg a cheque from one asset account to another of a different type. Should fail''' ta_asset1 = data.TransferAccounts().initial_balance() ta_asset2 = data.TransferAccounts().initial_balance() source = ta_asset1.source target = ta_asset2.target instrument = instrument_constructor(source, target, 50) with error.expected(ReturnValueError): transfer(instrument, source, target) ta_asset2.assert_balances(-100, 100, 0)
def test_cancel_instrument(instrument_constructor): '''Cancel an instrument and make sure it can't be deposited.''' accounts = data.TransferAccounts().initial_balance() instrument = instrument_constructor(accounts.source, accounts.target, 50) write(instrument) instrument.cancel() with error.expected(ReturnValueError): instrument.deposit(accounts.target.nym, accounts.target) accounts.assert_balances(-100, 100, 0)
def prepared_accounts(request): accts = data.TransferAccounts() accts.initial_balance() return accts