def test_student_accommodation(self): daft = Daft() daft.set_listing_type(RentType.STUDENT_ACCOMMODATION) daft.set_university(University.TCD) daft.set_student_accommodation_type( StudentAccommodationType.APARTMENTS) daft.set_min_price(800) daft.set_max_price(1500) daft.set_sort_by(SortType.PRICE) daft.set_sort_order(SortOrder.ASCENDING) listings = daft.search() self.assertTrue(len(listings) > 0)
def test_sort_by_price(self): daft = Daft() daft.set_county("Dublin City") daft.set_area("Dublin 15") daft.set_listing_type(SaleType.PROPERTIES) daft.set_min_price(150000) daft.set_max_price(175000) daft.set_sort_by(SortType.PRICE) listings = daft.search(fetch_all=False) listing = listings[0] price = listing.price self.assertTrue(len(listings) > 0) self.assertTrue(int(price) <= 175000)
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
def test_sort_by_price(self): daft = Daft() daft.set_county("Dublin City") daft.set_area("Dublin 15") daft.set_listing_type(SaleType.PROPERTIES) daft.set_min_price(150000) daft.set_max_price(175000) daft.set_sort_by(SortType.PRICE) listings = daft.search() listing = listings[0] price = listing.price price = price.split() price = price[len(price) - 1] price = price[1:] price = price.replace(',', '') self.assertTrue(len(listings) > 0) self.assertTrue(int(price) <= 175000)
def test_sort_by_date_ascending(self): daft = Daft() daft.set_county("Dublin City") daft.set_area("Dublin 15") daft.set_listing_type(SaleType.PROPERTIES) daft.set_sort_order(SortOrder.ASCENDING) daft.set_sort_by(SortType.DATE) daft.set_min_price(150000) daft.set_max_price(175000) listings = daft.search() self.assertTrue(len(listings) > 0) first = listings[0].posted_since.split() last = listings[-1].posted_since.split() first_date = time.strptime(first[0], "%d/%m/%Y") last_date = time.strptime(last[0], "%d/%m/%Y") self.assertTrue(first_date < last_date)
def test_sort_by_price(self): daft = Daft() daft.set_county("Dublin City") daft.set_area("Dublin 15") daft.set_listing_type(SaleType.PROPERTIES) daft.set_min_price(150000) daft.set_max_price(175000) daft.set_sort_by(SortType.PRICE) listings = daft.get_listings() listing = listings[0] price = listing.get_price() if "AMV" in price: price = price[6:] else: price = price[1:] print price price = price.replace(',', '') self.assertTrue(len(listings) > 0) self.assertTrue(int(price) <= 175000)
# Example to print a Listing object as dict. from daftlistings import Daft, RentType, SortOrder, SortType import pprint daft = Daft(debug=True) daft.set_county('Dublin') daft.set_listing_type(RentType.APARTMENTS) daft.set_sort_order(SortOrder.ASCENDING) daft.set_sort_by(SortType.PRICE) daft.set_with_photos(True) daft.set_open_viewing(True) listings = daft.search() first = listings[0] pprint.pprint(first.as_dict())