use fastapi to test

This commit is contained in:
Thephaseless 2024-09-13 18:28:36 +00:00
parent ed9350af82
commit baae2fddeb
2 changed files with 16 additions and 8 deletions

View File

@ -29,7 +29,8 @@ COPY novnc.sh .
RUN ./novnc.sh
ENV DISPLAY=:1.0
COPY . .
COPY fix_nodriver.py ./
RUN . /app/.venv/bin/activate && python fix_nodriver.py
COPY . .
RUN /usr/local/share/desktop-init.sh && poetry run pytest
CMD /usr/local/share/desktop-init.sh && . /app/.venv/bin/activate && python main.py

View File

@ -1,18 +1,25 @@
import pytest
from http import HTTPStatus
from main import read_item
import pytest
from starlette.testclient import TestClient
from main import app
from src.models.requests import LinkRequest
client = TestClient(app)
test_websites = [
"https://ext.to/",
"https://btmet.com/",
"https://extratorrent.st/",
"https://idope.se/",
]
pytest_plugins = ("pytest_asyncio",)
@pytest.mark.parametrize("website", test_websites)
@pytest.mark.asyncio
async def test_bypass(website: str):
await read_item(LinkRequest(url=website, maxTimeout=5, cmd=""))
def test_bypass(website: str):
response = client.post(
"/v1",
json=LinkRequest(url=website, maxTimeout=60, cmd="request.get").model_dump(),
)
assert response.status_code == HTTPStatus.OK