コード例 #1
0
    def test_elastic_to_oikotie_missing__project_description(
            self, description, link, expected):
        elastic_apartment = ApartmentMinimalFactory(
            project_description=description, url=link)
        formed_description = form_description(elastic_apartment)

        assert formed_description.strip() == expected.strip()
コード例 #2
0
def elastic_apartments():
    elastic_apartments = ApartmentMinimalFactory.build_for_sale_batch(10)
    try:
        for item in elastic_apartments:
            item.save(refresh="wait_for")
        yield elastic_apartments
    except SkipTest:
        skip()
コード例 #3
0
 def test_elastic_to_oikotie_missing__housing_company__project_city(self):
     elastic_apartment = ApartmentMinimalFactory(project_city=None)
     try:
         map_oikotie_housing_company(elastic_apartment)
     except ValueError as e:
         assert "project_city" in str(e)
         return
     raise Exception("Missing project_city should have thrown a ValueError")
コード例 #4
0
 def test_elastic_to_etuovi_missing_apartment_project_building_type(self):
     elastic_apartment = ApartmentMinimalFactory(project_building_type=None)
     try:
         map_apartment_to_item(elastic_apartment)
     except ValueError as e:
         assert "project_building_type" in str(e)
         return
     raise Exception(
         "Missing project_building_type should have thrown a ValueError")
コード例 #5
0
def invalid_data_elastic_apartments_for_sale():
    # etuovi (and oikotie apartment) invalid data is in project_holding_type
    # oikotie apartment invalid data data is in project_new_development_status
    # oikotie housing company invalid data is in project_estate_agent_email

    # should fail with oikotie apartments and etuovi
    elastic_apartment_1 = ApartmentMinimalFactory.build(
        project_holding_type="some text",
        project_new_development_status="some text",
        apartment_state_of_sale=ApartmentStateOfSale.FOR_SALE,
        _language="fi",
    )
    # should fail with oikotie housing companies
    elastic_apartment_2 = ApartmentMinimalFactory.build(
        project_estate_agent_email="",
        apartment_state_of_sale=ApartmentStateOfSale.FOR_SALE,
        _language="fi",
    )
    # should fail with oikotie apartments and housing companies
    elastic_apartment_3 = ApartmentMinimalFactory.build(
        project_new_development_status="some text",
        project_estate_agent_email="",
        apartment_state_of_sale=ApartmentStateOfSale.FOR_SALE,
        _language="fi",
    )

    apartments = [
        elastic_apartment_1,
        elastic_apartment_2,
        elastic_apartment_3,
    ]
    for item in apartments:
        item.save()
    sleep(1)
    yield elastic_apartments

    for item in apartments:
        item.delete()
    sleep(1)
コード例 #6
0
def elastic_apartments():
    sale_apartments = []
    while not sale_apartments:
        elastic_apartments = ApartmentMinimalFactory.create_batch(20)
        sale_apartments = [
            item for item in elastic_apartments
            if item.apartment_state_of_sale == "FOR_SALE"
            and item._language == "fi"
        ]
    try:
        for item in elastic_apartments:
            item.save()
        sleep(3)
        yield elastic_apartments
    except SkipTest:
        skip()
コード例 #7
0
 def test_apartment_minimal_to_item_mapping_types(self):
     apartment = ApartmentMinimalFactory()
     item = map_apartment_to_item(apartment)
     check_dataclass_typing(item)
コード例 #8
0
 def test_elastic_to_oikotie__apartment_minimal__mapping_types(self):
     elastic_apartment = ApartmentMinimalFactory()
     oikotie_apartment = map_oikotie_apartment(elastic_apartment)
     check_dataclass_typing(oikotie_apartment)