コード例 #1
0
ファイル: test_bank.py プロジェクト: Elgedr/Python
def test_bank():
    """Test bank class."""
    person2 = Person("Robert", "Soidla", 19)
    person1 = Person("Ellina", "Gedrojets", 18)
    bank1 = Bank("Swed")
    assert bank1.add_customer(person2) is True
    assert person2 in bank1.customers
    assert bank1.add_customer(person2) is False
    assert bank1.remove_customer(person2) is True
    assert bank1.remove_customer(person1) is False
    assert bank1.__repr__() == bank1.name
コード例 #2
0
def test_bank_definition():
    """Test Bank class."""
    p1 = Person('Jack', 'Jackson', 19)
    p2 = Person('Anna', 'Dark', 194)
    p3 = Person('Igor', 'Smirnov', 33)
    b1 = Bank('NotSwedBank')
    b2 = Bank('CoolerThanLHV')
    assert b1.add_customer(p1) is True
    assert p1 in b1.customers
    assert b2.add_customer(p2) is True
    assert b2.add_customer(p3) is True
    assert p2 in b2.customers
    assert p3 in b2.customers
    assert b2.add_customer(p2) is False
    assert b2.remove_customer(Person('Jey', 'Winston', 57)) is False
    assert p1.bank_account.balance == 0
    assert len(b2.customers) == 2
    assert b2.customers == [p2, p3]
    assert b2.remove_customer(p3) is True
    assert p3 not in b2.customers
    assert len(b2.customers) == 1
    assert b1.__repr__() == b1.name