def test_account_creation(client):
    testAccount = "Account1"

    response = client.post(f"/accounts/{testAccount}")
    assert response.status_code == 200
    assert response.json == asdict(Account(testAccount))

    response = client.get(f"/accounts/{testAccount}")
    assert response.status_code == 200
    assert response.json == asdict(Account(testAccount))
Beispiel #2
0
def test_can_add_negative_funds(bank):
    bank.create_account('Test')

    bank.add_funds('Test', -10)
    transaction = list(bank.transactions)[0]

    assert len(bank.transactions) == 1
    assert transaction.account == Account('Test')
    assert transaction.amount == -10
def test_cannot_modify_accounts_set(bank):
    accounts = bank.accounts
    accounts.add(Account('New Account'))

    assert len(bank.accounts) == 0
def test_accounts_are_immutable():
    account = Account('Immutable')
    with pytest.raises(Exception):
        # This operation should raise an exception
        account.name = 'Mutable'