From 8678b0bbe4193493549e4900b7822758fe039510 Mon Sep 17 00:00:00 2001 From: Cullen Watson Date: Fri, 19 Jul 2024 14:25:25 -0500 Subject: [PATCH] enh: test on pr (#174) --- .github/workflows/python-test.yml | 22 ++++++++++++++++++++++ poetry.toml | 2 ++ src/tests/test_all.py | 4 ++-- src/tests/test_glassdoor.py | 8 +++++--- src/tests/test_indeed.py | 6 ++++-- src/tests/test_linkedin.py | 7 ++----- src/tests/test_ziprecruiter.py | 5 ++--- 7 files changed, 39 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/python-test.yml create mode 100644 poetry.toml diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml new file mode 100644 index 0000000..daaa8cd --- /dev/null +++ b/.github/workflows/python-test.yml @@ -0,0 +1,22 @@ +name: Python Tests + +on: + pull_request: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.8' + - name: Install dependencies + run: | + pip install poetry + poetry install + - name: Run tests + run: poetry run pytest src/tests/ diff --git a/poetry.toml b/poetry.toml new file mode 100644 index 0000000..ab1033b --- /dev/null +++ b/poetry.toml @@ -0,0 +1,2 @@ +[virtualenvs] +in-project = true diff --git a/src/tests/test_all.py b/src/tests/test_all.py index c34524e..56cdb66 100644 --- a/src/tests/test_all.py +++ b/src/tests/test_all.py @@ -5,10 +5,10 @@ import pandas as pd def test_all(): result = scrape_jobs( site_name=["linkedin", "indeed", "zip_recruiter", "glassdoor"], - search_term="software engineer", + search_term="engineer", results_wanted=5, ) assert ( - isinstance(result, pd.DataFrame) and not result.empty + isinstance(result, pd.DataFrame) and len(result) == 20 ), "Result should be a non-empty DataFrame" diff --git a/src/tests/test_glassdoor.py b/src/tests/test_glassdoor.py index 6ef36ae..29e3aa4 100644 --- a/src/tests/test_glassdoor.py +++ b/src/tests/test_glassdoor.py @@ -2,10 +2,12 @@ from ..jobspy import scrape_jobs import pandas as pd -def test_indeed(): +def test_glassdoor(): result = scrape_jobs( - site_name="glassdoor", search_term="software engineer", country_indeed="USA" + site_name="glassdoor", + search_term="engineer", + results_wanted=5, ) assert ( - isinstance(result, pd.DataFrame) and not result.empty + isinstance(result, pd.DataFrame) and len(result) == 5 ), "Result should be a non-empty DataFrame" diff --git a/src/tests/test_indeed.py b/src/tests/test_indeed.py index 2eef36b..62bfff6 100644 --- a/src/tests/test_indeed.py +++ b/src/tests/test_indeed.py @@ -4,8 +4,10 @@ import pandas as pd def test_indeed(): result = scrape_jobs( - site_name="indeed", search_term="software engineer", country_indeed="usa" + site_name="indeed", + search_term="engineer", + results_wanted=5, ) assert ( - isinstance(result, pd.DataFrame) and not result.empty + isinstance(result, pd.DataFrame) and len(result) == 5 ), "Result should be a non-empty DataFrame" diff --git a/src/tests/test_linkedin.py b/src/tests/test_linkedin.py index 8db0a62..aa199e7 100644 --- a/src/tests/test_linkedin.py +++ b/src/tests/test_linkedin.py @@ -3,10 +3,7 @@ import pandas as pd def test_linkedin(): - result = scrape_jobs( - site_name="linkedin", - search_term="software engineer", - ) + result = scrape_jobs(site_name="linkedin", search_term="engineer", results_wanted=5) assert ( - isinstance(result, pd.DataFrame) and not result.empty + isinstance(result, pd.DataFrame) and len(result) == 5 ), "Result should be a non-empty DataFrame" diff --git a/src/tests/test_ziprecruiter.py b/src/tests/test_ziprecruiter.py index cd1c8ee..374e732 100644 --- a/src/tests/test_ziprecruiter.py +++ b/src/tests/test_ziprecruiter.py @@ -4,10 +4,9 @@ import pandas as pd def test_ziprecruiter(): result = scrape_jobs( - site_name="zip_recruiter", - search_term="software engineer", + site_name="zip_recruiter", search_term="software engineer", results_wanted=5 ) assert ( - isinstance(result, pd.DataFrame) and not result.empty + isinstance(result, pd.DataFrame) and len(result) == 5 ), "Result should be a non-empty DataFrame"