Skip to content

Instantly share code, notes, and snippets.

@timurbakibayev
Created February 21, 2022 17:12
Show Gist options
  • Save timurbakibayev/23e745fb15a7e65de7fe709c4566f6d3 to your computer and use it in GitHub Desktop.
Save timurbakibayev/23e745fb15a7e65de7fe709c4566f6d3 to your computer and use it in GitHub Desktop.
new tests
import pytest
from decimal import Decimal
from main import Account
class TestNormalAccount:
def test_add_amount(self) -> None:
account = Account(
amount=Decimal(10),
blocked=Decimal(0),
)
new_account = account.add_amount(Decimal(5))
assert new_account.available_amount == 15
assert account.available_amount == 10
def test_block_amount(self) -> None:
account = Account(
amount=Decimal(10),
blocked=Decimal(0),
)
with pytest.raises(ValueError):
account.block_amount(Decimal(11))
assert account.available_amount == 10
new_account = account.block_amount(Decimal(7))
assert new_account.available_amount == 3
assert account.available_amount == 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment