Ejemplo n.º 1
0
 def test_properties(self):
     daft = Daft()
     daft.set_county("Dublin City")
     daft.set_area("Dublin 15")
     daft.set_added_since(14)
     daft.set_listing_type(SaleType.PROPERTIES)
     daft.set_property_type([PropertyType.HOUSE])
     listings = daft.search(fetch_all=False)
     self.assertTrue(len(listings) > 0)
     first = listings[1]
     self.assertIsNotNone(first.agent_id)
     self.assertIsNotNone(first.commercial_area_size)
     self.assertIsNotNone(first.contact_number)
     self.assertIsNotNone(first.daft_link)
     self.assertIsNotNone(first.date_insert_update)
     self.assertIsNotNone(first.facilities)
     self.assertIsNotNone(first.formalised_address)
     self.assertIsNotNone(first.id)
     self.assertIsNotNone(first.bathrooms)
     self.assertIsNotNone(first.bedrooms)
     self.assertIsNotNone(first.overviews)
     self.assertIsNotNone(first.price)
     self.assertIsNotNone(first.search_type)
     self.assertIsNotNone(first.shortcode)
     self.assertIsNotNone(first.views)
     self.assertIsNotNone(first.features)
     self.assertIsNotNone(first.advertiser_name)
     self.assertIsNotNone(first.date_insert_update)
     self.assertIsNotNone(first.hires_images)
     self.assertIsNotNone(first.images)
Ejemplo n.º 2
0
    def test_apartments_to_let(self):
        daft = Daft()
        daft.set_county("Dublin")
        daft.set_couples_accepted(True)
        daft.set_with_photos(True)
        daft.set_ensuite_only(True)
        daft.set_area_type(AreaType.TRANSPORT_ROUTE)
        daft.set_public_transport_route(TransportRoute.DART)
        daft.set_listing_type(RentType.APARTMENTS)
        daft.set_added_since(7)
        daft.set_gender(Gender.EITHER)
        listings = daft.search()

        self.assertTrue(len(listings) > 0)
Ejemplo n.º 3
0
def initialize_daft_api_client():
    daft_client = Daft()
    daft_client.set_county(config.COUNTY)
    daft_client.set_listing_type(config.LISTING_TYPE)
    daft_client.set_min_price(config.MIN_PRICE)
    daft_client.set_max_price(config.MAX_PRICE)
    daft_client.set_with_photos(config.WITH_PHOTOS)
    daft_client.set_added_since(config.ADDED_SINCE)
    daft_client.set_area(config.AREAS)
    daft_client.set_sort_order(config.SORT_ORDER)
    daft_client.set_sort_by(config.SORT_BY)
    daft_client.set_furnished(config.FURNISHED)
    daft_client.set_min_beds(config.MIN_BEDS)
    daft_client.set_min_lease(config.MIN_LEASE)
    return daft_client
Ejemplo n.º 4
0
 def test_properties(self):
     daft = Daft()
     daft.set_county("Dublin City")
     daft.set_area("Dublin 15")
     daft.set_added_since(14)
     daft.set_listing_type(SaleType.PROPERTIES)
     listings = daft.search()
     self.assertTrue(len(listings) > 0)
     first = listings[1]
     self.assertIsNotNone(first.facilities)
     self.assertIsNotNone(first.formalised_address)
     self.assertIsNotNone(first.address_line_1)
     self.assertIsNotNone(first.address_line_2)
     self.assertIsNotNone(first.agent)
     self.assertIsNotNone(first.agent_id)
     self.assertIsNotNone(first.agent_url)
     self.assertIsNotNone(first.bathrooms)
     self.assertIsNotNone(first.bedrooms)
     self.assertIsNotNone(first.county)
     self.assertIsNotNone(first.daft_link)
     self.assertIsNotNone(first.features)
     self.assertIsNotNone(first.id)
     self.assertIsNotNone(first.search_type)
     self.assertIsNotNone(first.dwelling_type)
Ejemplo n.º 5
0
    def test_search_properties_for_sale(self, mock_post):
        url = "https://search-gateway.dsch.ie/v1/listings"
        payload = {
            "section":
            "residential-for-sale",
            "andFilters": [{
                "name":
                "facilities",
                "values": [
                    "wired-for-cable-television",
                    "alarm",
                    "wheelchair-access",
                    "gas-fired-central-heating",
                ],
            }],
            "ranges": [
                {
                    "name": "salePrice",
                    "from": "250000",
                    "to": "300000"
                },
                {
                    "name": "numBeds",
                    "from": "3",
                    "to": "3"
                },
                {
                    "name": "ber",
                    "from": "0",
                    "to": "0"
                },
                {
                    "name": "floorSize",
                    "from": "1000",
                    "to": "1000"
                },
                {
                    "name": "firstPublishDate",
                    "from": "now-14d/d",
                    "to": ""
                },
            ],
            "geoFilter": {
                "storedShapeIds": ["3"],
                "geoSearchType": "STORED_SHAPES"
            },
            "sort":
            "priceAsc",
            "paging": {
                "from": "0",
                "pagesize": "50"
            },
        }
        headers = {
            "Content-Type": "application/json",
            "brand": "daft",
            "platform": "web",
        }

        daft = Daft()

        daft.set_search_type(SearchType.RESIDENTIAL_SALE)
        daft.set_location(Location.KILDARE)
        daft.set_location("Kildare")
        daft.set_sort_type(SortType.PRICE_ASC)
        daft.set_max_price(300000)
        daft.set_min_price(250000)
        daft.set_min_beds(3)
        daft.set_max_beds(3)
        daft.set_min_ber(Ber.A1)
        daft.set_max_ber(Ber.A1)
        daft.set_max_floor_size(1000)
        daft.set_min_floor_size(1000)
        daft.set_added_since(AddedSince.DAYS_14)
        daft.set_facility(Facility.WIRED_FOR_CABLE_TELEVISION)
        daft.set_facility(Facility.ALARM)
        daft.set_facility(Facility.WHEELCHAIR_ACCESS)
        daft.set_facility(Facility.CENTRAL_HEATING_GAS)
        daft.search()

        mock_post.assert_called_with(url, headers=headers, json=payload)
Ejemplo n.º 6
0
    def test_search_properties_for_rent(self, mock_post):
        url = "https://search-gateway.dsch.ie/v1/listings"
        payload = {
            "section":
            "residential-to-rent",
            "andFilters": [{
                "name": "facilities",
                "values": ["alarm", "parking", "cable-television"],
            }],
            "ranges": [
                {
                    "name": "rentalPrice",
                    "from": "2000",
                    "to": "2500"
                },
                {
                    "name": "numBeds",
                    "from": "1",
                    "to": "2"
                },
                {
                    "name": "ber",
                    "from": "0",
                    "to": "0"
                },
                {
                    "name": "floorSize",
                    "from": "1000",
                    "to": "1000"
                },
                {
                    "name": "firstPublishDate",
                    "from": "now-14d/d",
                    "to": ""
                },
            ],
            "geoFilter": {
                "storedShapeIds": ["3"],
                "geoSearchType": "STORED_SHAPES"
            },
            "sort":
            "priceDesc",
            "paging": {
                "from": "0",
                "pagesize": "50"
            },
        }
        headers = {
            "Content-Type": "application/json",
            "brand": "daft",
            "platform": "web",
        }

        daft = Daft()

        daft.set_search_type(SearchType.RESIDENTIAL_RENT)
        daft.set_location(Location.KILDARE)
        daft.set_location("Kildare")
        daft.set_sort_type(SortType.PRICE_DESC)
        daft.set_max_price(2500)
        daft.set_min_price(2000)
        daft.set_min_beds(1)
        daft.set_max_beds(2)
        daft.set_min_ber(Ber.A1)
        daft.set_max_ber(Ber.A1)
        daft.set_max_floor_size(1000)
        daft.set_min_floor_size(1000)
        daft.set_added_since(AddedSince.DAYS_14)
        daft.set_facility(Facility.ALARM)
        daft.set_facility(Facility.PARKING)
        daft.set_facility(Facility.CABLE_TELEVISION)
        daft.search()

        mock_post.assert_called_with(url, headers=headers, json=payload)