def test_add_apartment(): container = [] apartment = create_apartment(2, 22, 1_000_000, 'Московский') add_apartment(container, apartment) assert len(container) == 1 assert apartment in container
def test_add_one_apartment_to_empty_container(): container = [] apartment = create_apartment('2-х комнатная квартира', 2, 47, 'Вахитовский район', 'Вишневского', '51', '44', 4_300_000) add_apartment(container, apartment) assert len(container) == 1 assert apartment in container
def test_search_apartments_with_search_regions_and_price_parameter(): container = [] apartment1 = create_apartment('2-х комнатная квартира', 2, 47, 'Вахитовский район', 'Вишневского', '51', '44', 4_300_000) apartment2 = create_apartment('1 комнатная квартира', 1, 27, 'Авиастроительный район', 'Лукина', '1', '25', 2_000_000) apartment3 = create_apartment('1 комнатная квартира', 1, 35, 'Приволжский район', 'Профессора Камая', '8', '45', 3_200_000) add_apartment(container, apartment1) add_apartment(container, apartment2) add_apartment(container, apartment3) container_before_search = container[:] expected = [apartment3] result = search_apartments( container, search_regions=['Вахитовский район', 'Приволжский район'], search_price=3_500_000) assert result == expected assert container_before_search == container
def test_search_apartment(): apartments = [] one_room = create_apartment(1, 23, 1_500_000, 'Ново-Савиноский') three_rooms = create_apartment(3, 90, 4_400_000, 'Московский') two_rooms = create_apartment(2, 20, 2_700_000, 'Советский') add_apartment(apartments, one_room) add_apartment(apartments, three_rooms) add_apartment(apartments, two_rooms) founded_apartment = [{ 'rooms': 2, 'square': 20, 'price': 2700000, 'district': 'Советский' }] result = search_apartment(apartments, 'Советский') assert founded_apartment == result
def test_search_apartments_without_search_parameters(): container = [] apartment1 = create_apartment('2-х комнатная квартира', 2, 47, 'Вахитовский район', 'Вишневского', '51', '44', 4_300_000) apartment2 = create_apartment('1 комнатная квартира', 1, 27, 'Авиастроительный район', 'Лукина', '1', '25', 2_000_000) apartment3 = create_apartment('1 комнатная квартира', 1, 35, 'Приволжский район', 'Профессора Камая', '8', '45', 3_200_000) add_apartment(container, apartment1) add_apartment(container, apartment2) add_apartment(container, apartment3) expected = [apartment1, apartment2, apartment3] result = search_apartments(container) assert result == expected
from app.lib import create_apartment, add_apartment, search_apartment, search_price apartments = [] one_room = create_apartment(1, 23, 1_500_000, 'Ново-Савиноский') three_rooms = create_apartment(3, 90, 4_400_000, 'Московский') two_rooms = create_apartment(2, 20, 2_700_000, 'Советский') print(add_apartment(apartments, one_room)) print(add_apartment(apartments, two_rooms)) print(add_apartment(apartments, three_rooms)) print(search_apartment(apartments, 'советский')) print(search_apartment(apartments, 'московск')) print(search_price(apartments, 1_500_000))