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)
def test_apartments_to_rent(self): daft = Daft() daft.set_search_type(SearchType.RESIDENTIAL_RENT) daft.set_property_type(PropertyType.APARTMENT) daft.set_location(Location.DUBLIN) listings = daft.search(max_pages=1) self.assertTrue(len(listings) > 0) self.assertGreater(daft.total_results, 0)
def test_studios_to_rent(self): daft = Daft() daft.set_search_type(SearchType.RESIDENTIAL_RENT) daft.set_property_type(PropertyType.STUDIO_APARTMENT) daft.set_location(Location.DUBLIN) listings = daft.search(max_pages=1) self.assertTrue(len(listings) > 0) self.assertTrue(listings[0].bedrooms == "1 bed") self.assertGreater(daft.total_results, 0)
from daftlistings import Daft, Location, SearchType, PropertyType daft = Daft() daft.set_location(Location.DUBLIN) daft.set_search_type(SearchType.RESIDENTIAL_SALE) daft.set_property_type(PropertyType.HOUSE) daft.set_min_price(400000) daft.set_max_price(500000) listings = daft.search() for listing in listings: print(listing.title) print(listing.price) print(listing.daft_link) print()
from daftlistings import Daft, Location, SearchType, PropertyType, Facility daft = Daft() daft.set_location(Location.DUBLIN) daft.set_search_type(SearchType.RESIDENTIAL_RENT) daft.set_property_type(PropertyType.APARTMENT) daft.set_facility(Facility.PARKING) daft.set_facility(Facility.ALARM) listings = daft.search() for listing in listings: print(listing.title) print(listing.price) print(listing.daft_link) print()