17 lines
540 B
Python
17 lines
540 B
Python
from oop_ex import AlertService, BankAccount, EmailNotifier, SmsNotifier
|
|
|
|
|
|
def test_bank_account() -> None:
|
|
acc = BankAccount(100)
|
|
acc.deposit(50)
|
|
assert acc.balance == 150
|
|
assert acc.withdraw(40) is True
|
|
assert acc.balance == 110
|
|
assert acc.withdraw(500) is False
|
|
assert acc.balance == 110
|
|
|
|
|
|
def test_alert_service_protocol_composition() -> None:
|
|
svc = AlertService([EmailNotifier("ops@example.com"), SmsNotifier("+48123456789")])
|
|
assert svc.broadcast("CPU 95%") == ["[email] CPU 95%", "[sms] CPU 95%"]
|