skip if test if client cant reach

This commit is contained in:
Thephaseless 2024-10-21 13:19:31 +00:00
parent 9ca2059b91
commit 5a40851c22

View File

@ -1,6 +1,7 @@
from http import HTTPStatus
from time import sleep
import httpx
import pytest
from starlette.testclient import TestClient
@ -22,11 +23,15 @@ test_websites = [
@pytest.mark.parametrize("website", test_websites)
def test_bypass(website: str):
sleep(3)
test_request = httpx.get(
website,
)
if test_request.status_code != HTTPStatus.OK:
pytest.skip()
response = client.post(
"/v1",
json=LinkRequest(url=website, maxTimeout=30, cmd="request.get").model_dump(),
)
if response.status_code == HTTPStatus.TOO_MANY_REQUESTS:
# if rate limited
pytest.skip()
assert response.status_code == HTTPStatus.OK