mirror of
https://github.com/ThePhaseless/Byparr.git
synced 2025-03-15 09:50:20 +08:00
use fastapi to test
This commit is contained in:
parent
ed9350af82
commit
baae2fddeb
@ -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
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user