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
|
RUN ./novnc.sh
|
||||||
ENV DISPLAY=:1.0
|
ENV DISPLAY=:1.0
|
||||||
|
|
||||||
COPY . .
|
COPY fix_nodriver.py ./
|
||||||
RUN . /app/.venv/bin/activate && python 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
|
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
|
from src.models.requests import LinkRequest
|
||||||
|
|
||||||
|
client = TestClient(app)
|
||||||
|
|
||||||
test_websites = [
|
test_websites = [
|
||||||
"https://ext.to/",
|
"https://ext.to/",
|
||||||
"https://btmet.com/",
|
"https://btmet.com/",
|
||||||
"https://extratorrent.st/",
|
"https://extratorrent.st/",
|
||||||
"https://idope.se/",
|
"https://idope.se/",
|
||||||
]
|
]
|
||||||
pytest_plugins = ("pytest_asyncio",)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("website", test_websites)
|
@pytest.mark.parametrize("website", test_websites)
|
||||||
@pytest.mark.asyncio
|
def test_bypass(website: str):
|
||||||
async def test_bypass(website: str):
|
response = client.post(
|
||||||
await read_item(LinkRequest(url=website, maxTimeout=5, cmd=""))
|
"/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