-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
284 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
name: ci | ||
requires: | ||
- unit-tests | ||
on: | ||
push: | ||
branches: ["master"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Unit Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
unit-tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install pdm | ||
run: pip install pdm | ||
|
||
- name: Install project dependencies | ||
run: pdm install | ||
|
||
- name: Run tests | ||
run: PYTHONPATH=. pdm run pytest api/backend/tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import pytest | ||
from unittest.mock import AsyncMock, patch, MagicMock | ||
from api.backend.tests.factories.job_factory import create_job | ||
from api.backend.models import JobOptions | ||
from api.backend.scraping import create_driver | ||
|
||
|
||
mocked_job = create_job( | ||
job_options=JobOptions( | ||
multi_page_scrape=False, custom_headers={}, proxies=["127.0.0.1:8080"] | ||
) | ||
).model_dump() | ||
|
||
|
||
@pytest.mark.asyncio | ||
@patch("seleniumwire.webdriver.Chrome.get") | ||
async def test_proxy(mock_get: AsyncMock): | ||
# Mock the response of the requests.get call | ||
mock_response = MagicMock() | ||
mock_get.return_value = mock_response | ||
|
||
driver = create_driver(proxies=["127.0.0.1:8080"]) | ||
assert driver is not None | ||
|
||
# Simulate a request | ||
driver.get("http://example.com") | ||
response = driver.last_request | ||
|
||
# Check if the proxy header is set correctly | ||
if response: | ||
assert response.headers["Proxy"] == "127.0.0.1:8080" | ||
|
||
driver.quit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,4 @@ services: | |
ports: | ||
- "8000:8000" | ||
volumes: | ||
- "$PWD/api:/project/app/api" | ||
- "$PWD/api:/project/api" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.