Skip to content

Commit

Permalink
Modified utils to handle multiple cities testing
Browse files Browse the repository at this point in the history
  • Loading branch information
RaresCode committed Aug 15, 2023
1 parent 9272e37 commit 445d060
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@ def scrape_jobs(scraper_data):
Get the job details from the scrapped page
"""
title = [title['job_title'] for title in scraper_data]
job_city = [city['city'] for city in scraper_data]
job_country = [country['country'] for country in scraper_data]
job_link = [job_link['job_link'] for job_link in scraper_data]

# Check if the cities list is a nested list
city_list = [city['city'] for city in scraper_data]
is_nested = all(isinstance(item, list) for item in city_list)

if is_nested:
job_city = [city['city'] for city in scraper_data]
else:
job_city = [[city['city']] for city in scraper_data]

return title, job_city, job_country, job_link

@staticmethod
Expand Down Expand Up @@ -52,9 +60,19 @@ def scrape_peviitor(company_name, country):
response_data = TestUtils._get_request(params)
while response_data:
all_future_title.extend([title['job_title'][0] for title in response_data])
all_future_job_city.extend([city['city'][0] for city in response_data])
# all_future_job_city.extend([city['city'][0] for city in response_data])
# all_future_job_city.extend([city['city'] for city in response_data])
all_future_job_country.extend([country['country'][0] for country in response_data])
all_future_job_link.extend([job_link['job_link'][0] for job_link in response_data])

# Check if the cities list is a nested list
city_list = [city['city'] for city in response_data]
is_nested = all(isinstance(item, list) for item in city_list)

if is_nested:
all_future_job_city.extend(city_list)
else:
all_future_job_city.extend([city['city'][0] for city in response_data])

page += 1
params = TestUtils._set_params(company_name, page, country)
Expand Down

0 comments on commit 445d060

Please sign in to comment.