Esempio n. 1
0
def test_several_rooms():
    bedroom1 = Room('child bedroom', 10)
    bedroom2 = Room('master bedroom', 15)
    bedroom3 = Room('guest bedroom', 8)

    assert sum([one_room.size
                for one_room in [bedroom1, bedroom2, bedroom3]]) == 33
Esempio n. 2
0
def test_mixed_neighborhood():
    Neighborhood.total_size = 0
    n = Neighborhood()

    houses = []
    for house_type in [Apartment, TownHouse, SingleFamilyHouse]:
        h = house_type()
        bedroom = Room('bedroom', 10)
        kitchen = Room('kitchen', 9)
        bathroom = Room('bathroom', 3)
        h.add_rooms(bedroom, kitchen, bathroom)
        houses.append(h)

        assert str(h) == f'''{house_type.__name__}:
bedroom, 10m
kitchen, 9m
bathroom, 3m'''

    n.add_houses(*houses)
    assert n.size() == Neighborhood.total_size
    assert dict(**n.house_types()) == {
        'Apartment': 1,
        'TownHouse': 1,
        'SingleFamilyHouse': 1
    }
Esempio n. 3
0
def test_large_single_family_house_tax():
    h = SingleFamilyHouse(300)
    bedroom = Room('bedroom', 100)
    kitchen = Room('kitchen', 90)
    bathroom = Room('bathroom', 30)
    h.add_rooms(bedroom, kitchen, bathroom)

    assert h.calculate_tax() == 28500
Esempio n. 4
0
def test_small_single_family_house_tax():
    h = SingleFamilyHouse()
    bedroom = Room('bedroom', 10)
    kitchen = Room('kitchen', 9)
    bathroom = Room('bathroom', 3)
    h.add_rooms(bedroom, kitchen, bathroom)

    assert h.calculate_tax() == 2640
Esempio n. 5
0
def test_townhouse_tax():
    h = TownHouse()
    bedroom = Room('bedroom', 10)
    kitchen = Room('kitchen', 9)
    bathroom = Room('bathroom', 3)
    h.add_rooms(bedroom, kitchen, bathroom)

    assert h.calculate_tax() == 2200
Esempio n. 6
0
def test_apartment_tax():
    h = Apartment()
    bedroom = Room('bedroom', 10)
    kitchen = Room('kitchen', 9)
    bathroom = Room('bathroom', 3)
    h.add_rooms(bedroom, kitchen, bathroom)

    assert h.calculate_tax() == 1650
Esempio n. 7
0
def test_small_house():
    h = House()
    bedroom = Room('bedroom', 10)
    kitchen = Room('kitchen', 9)
    bathroom = Room('bathroom', 3)
    h.add_rooms(bedroom, kitchen, bathroom)

    assert h.size() == 22
    assert len(h.rooms) == 3
    assert str(h) == '''House:
Esempio n. 8
0
def test_small_house_add_equal_then_more():
    h = House(15)
    assert h.available_space == 15
    bedroom = Room('bedroom', 15)
    h.add_rooms(bedroom)
    assert h.size() == 15
    assert h.available_space == 15

    tiny_room = Room('very small closet', 0.01)
    with pytest.raises(NotEnoughSpaceError):
        h.add_rooms(tiny_room)
Esempio n. 9
0
def test_small_house_with_plus():
    h = House()
    bedroom = Room('bedroom', 10)
    kitchen = Room('kitchen', 9)
    bathroom = Room('bathroom', 3)
    h += bedroom
    h += kitchen
    h += bathroom

    assert h.size() == 22
    assert len(h.rooms) == 3
    assert str(h) == '''House:
Esempio n. 10
0
def test_palace():
    h = House(175)

    for i in range(10):
        h.add_rooms(Room(f'bedroom {i}', 15))

    for i in range(5):
        h.add_rooms(Room(f'bathroom {i}', 3))

    for i in range(3):
        h.add_rooms(Room(f'kitchen {i}', 3))

    assert h.size() == 174
    assert len(h.rooms) == 18
Esempio n. 11
0
def test_one_neighborhood():
    Neighborhood.total_size = 0
    n = Neighborhood()

    houses = []
    for i in range(3):
        h = House()
        bedroom = Room('bedroom', 10)
        kitchen = Room('kitchen', 9)
        bathroom = Room('bathroom', 3)
        h.add_rooms(bedroom, kitchen, bathroom)
        houses.append(h)

    n.add_houses(*houses)
    assert n.size() == Neighborhood.total_size
Esempio n. 12
0
def test_zero_size_house_add_room():
    h = House(0)
    assert h.available_space == 0
    bedroom = Room('bedroom', 10)

    with pytest.raises(NotEnoughSpaceError):
        h.add_rooms(bedroom)
Esempio n. 13
0
def test_str():
    my_office = Room('office', 10)
    assert str(my_office) == 'office, 10m'
Esempio n. 14
0
def test_simple():
    my_office = Room('office', 10)
    assert my_office.name == 'office'
    assert my_office.size == 10