usse/scrape/funda-scraper/tests/test_scrape.py
2023-12-22 15:26:01 +01:00

49 lines
1.8 KiB
Python

from funda_scraper.preprocess import preprocess_data
from funda_scraper.scrape import FundaScraper
class TestFundaScraper(object):
def test_rent(self):
scraper = FundaScraper(area="amsterdam", want_to="rent", find_past=False, page_start=1, n_pages=1)
df = scraper.run(raw_data=True)
assert len(scraper.links) == 15
assert df.shape == (15, 27)
assert df['city'].unique()[0] == 'amsterdam'
df = preprocess_data(df, is_past=False)
assert df.shape[0] > 12
assert df.shape[1] == 17
def test_rent_past(self):
scraper = FundaScraper(area="amsterdam", want_to="rent", find_past=True, page_start=1, n_pages=1)
df = scraper.run(raw_data=True)
assert len(scraper.links) == 15
assert df.shape == (15, 30)
assert df['city'].unique()[0] == 'amsterdam'
df = preprocess_data(df, is_past=True)
assert df.shape[0] > 12
assert df.shape[1] == 17
def test_buy(self):
scraper = FundaScraper(area="amsterdam", want_to="buy", find_past=False, page_start=1, n_pages=1)
df = scraper.run(raw_data=True)
assert len(scraper.links) == 15
assert df.shape == (15, 27)
assert df['city'].unique()[0] == 'amsterdam'
df = preprocess_data(df, is_past=False)
assert df.shape[0] > 12
assert df.shape[1] == 17
def test_buy_past(self):
scraper = FundaScraper(area="amsterdam", want_to="buy", find_past=True, page_start=1, n_pages=1)
df = scraper.run(raw_data=True)
assert len(scraper.links) == 15
assert df.shape == (15, 30)
assert df['city'].unique()[0] == 'amsterdam'
df = preprocess_data(df, is_past=True)
assert df.shape[0] > 12
assert df.shape[1] == 17