mirror of https://github.com/Bunsly/JobSpy
debugging
parent
ea3db1ca37
commit
6ac7337c0f
|
@ -1,4 +1,4 @@
|
|||
name: API Check
|
||||
name: Test API
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
|
@ -16,36 +16,36 @@ jobs:
|
|||
python-version: '3.10'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pip install -r requirements.txt
|
||||
run: pip install -r requirements.txt
|
||||
|
||||
- name: Install jq
|
||||
run: sudo apt-get install jq
|
||||
|
||||
- name: Start JobSpy FastAPI app
|
||||
run: |
|
||||
uvicorn main:app --host 0.0.0.0 --port 8000 &
|
||||
run: uvicorn main:app --host 0.0.0.0 --port 8000 &
|
||||
|
||||
- name: Wait for server to be up
|
||||
run: sleep 10
|
||||
run: |
|
||||
for i in {1..10}; do
|
||||
curl -s http://0.0.0.0:8000/api/v1/jobs && break || sleep 1
|
||||
done
|
||||
|
||||
- name: Verify results count
|
||||
run: |
|
||||
curl -X 'POST' -H 'Content-Type: application/json' -d '{
|
||||
"site_type": ["indeed", "linkedin", "zip_recruiter"],
|
||||
"search_term": "software engineer",
|
||||
"location": "austin, tx",
|
||||
"distance": 10,
|
||||
"job_type": "fulltime",
|
||||
"results_wanted": 5
|
||||
}' http://0.0.0.0:8000/api/v1/jobs > response.json
|
||||
response=$(curl -s -X 'POST' -H 'Content-Type: application/json' -d '{
|
||||
...
|
||||
}' http://0.0.0.0:8000/api/v1/jobs -w "%{http_code}")
|
||||
|
||||
cat response.json
|
||||
|
||||
indeed_results=$(jq '.indeed.returned_results' response.json)
|
||||
linkedin_results=$(jq '.linkedin.returned_results' response.json)
|
||||
zip_recruiter_results=$(jq '.zip_recruiter.returned_results' response.json)
|
||||
status_code="${response: -3}"
|
||||
if [ "$status_code" != "200" ]; then
|
||||
echo "Error: Received status code $status_code"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "${response::-3}" > response.json
|
||||
|
||||
cat response.json
|
||||
|
||||
if [[ $indeed_results -ne 5 || $linkedin_results -ne 5 || $zip_recruiter_results -ne 5 ]]; then
|
||||
echo "Mismatch in results_wanted and returned_results:"
|
||||
echo "Indeed: Expected 5, Got $indeed_results"
|
||||
|
@ -53,9 +53,3 @@ jobs:
|
|||
echo "ZipRecruiter: Expected 5, Got $zip_recruiter_results"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Upload response.json as artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: response.json
|
||||
path: ./response.json
|
||||
|
|
Loading…
Reference in New Issue