def test_account_must_be_able_to_be_found_by_name(session): acc1 = create_account(session, u'Счет1') create_account(session, u'Счет2') acc = get_account_by_name(session, u'Счет1') assert acc.id == acc1.id acc = get_account_by_name(session, u'Счет3') assert acc == None create_account(session, u'Счет1') try: get_account_by_name(session, u'Счет1') assert False, 'MultipleResultsFound must be raised' except Account.MultipleResultsFound: pass
def test_accounts_tree(session): create_account(session, 'acc1') create_account(session, 'acc3', create_account(session, 'acc2')) session.commit() result = [r.name for r in get_toplevel_accounts(session)] assert u'acc1' in result assert u'acc2' in result assert len(result) == 2 acc = get_account_by_name(session, 'acc2') result = acc.subaccounts() assert len(result) == 1 assert result[0].name == 'acc3' result = result[0].parent_accounts assert len(result) == 1 assert result[0].name == 'acc2' result = result[0].parent_accounts assert result == []