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} assert n.calculate_tax() == 6490 assert n.find_with_room(name='bedroom', size=11) == set() assert len(n.find_with_room(name='bedroom', size=10)) == 3
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