Spaces:
Running
Running
File size: 1,547 Bytes
0a1b571 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
from math import inf
import pytest
from fastapi.testclient import TestClient
@pytest.fixture(scope="package")
def client():
from hibiapi.app import app, application
application.RATE_LIMIT_MAX = inf
with TestClient(app, base_url="http://testserver/api/tieba/") as client:
yield client
def test_post_list(client: TestClient):
response = client.get("post_list", params={"name": "minecraft"})
assert response.status_code == 200
if response.json()["error_code"] != "0":
pytest.xfail(reason=response.text)
def test_post_list_chinese(client: TestClient):
# NOTE: reference https://github.com/mixmoe/HibiAPI/issues/117
response = client.get("post_list", params={"name": "图拉丁"})
assert response.status_code == 200
if response.json()["error_code"] != "0":
pytest.xfail(reason=response.text)
def test_post_detail(client: TestClient):
response = client.get("post_detail", params={"tid": 1766018024})
assert response.status_code == 200
if response.json()["error_code"] != "0":
pytest.xfail(reason=response.text)
def test_subpost_detail(client: TestClient):
response = client.get(
"subpost_detail", params={"tid": 1766018024, "pid": 22616319749}
)
assert response.status_code == 200
assert int(response.json()["error_code"]) == 0
def test_user_profile(client: TestClient):
response = client.get("user_profile", params={"uid": 105525655})
assert response.status_code == 200
assert int(response.json()["error_code"]) == 0
|