More tests
This commit is contained in:
parent
01a409dc78
commit
a2cfc36dab
3 changed files with 97 additions and 7 deletions
|
@ -1,6 +1,8 @@
|
|||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from app import activitypub as ap
|
||||
from app.actor import LOCAL_ACTOR
|
||||
from app.database import Session
|
||||
|
||||
_ACCEPTED_AP_HEADERS = [
|
||||
|
@ -11,20 +13,41 @@ _ACCEPTED_AP_HEADERS = [
|
|||
]
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
def test_index(db: Session, client: TestClient):
|
||||
def test_index__html(db: Session, client: TestClient):
|
||||
response = client.get("/")
|
||||
assert response.status_code == 200
|
||||
assert response.headers["content-type"].startswith("text/html")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("accept", _ACCEPTED_AP_HEADERS)
|
||||
def test__ap_version(client, db, accept: str) -> None:
|
||||
response = client.get("/followers", headers={"Accept": accept})
|
||||
def test_index__ap(db: Session, client: TestClient, accept: str):
|
||||
response = client.get("/", headers={"Accept": accept})
|
||||
assert response.status_code == 200
|
||||
assert response.headers["content-type"] == "application/activity+json"
|
||||
assert response.headers["content-type"] == ap.AP_CONTENT_TYPE
|
||||
assert response.json() == LOCAL_ACTOR.ap_actor
|
||||
|
||||
|
||||
def test_followers__ap(client, db) -> None:
|
||||
response = client.get("/followers", headers={"Accept": ap.AP_CONTENT_TYPE})
|
||||
assert response.status_code == 200
|
||||
assert response.headers["content-type"] == ap.AP_CONTENT_TYPE
|
||||
assert response.json()["id"].endswith("/followers")
|
||||
|
||||
|
||||
def test__html(client, db) -> None:
|
||||
response = client.get("/followers", headers={"Accept": "application/activity+json"})
|
||||
def test_followers__html(client, db) -> None:
|
||||
response = client.get("/followers")
|
||||
assert response.status_code == 200
|
||||
assert response.headers["content-type"].startswith("text/html")
|
||||
|
||||
|
||||
def test_following__ap(client, db) -> None:
|
||||
response = client.get("/following", headers={"Accept": ap.AP_CONTENT_TYPE})
|
||||
assert response.status_code == 200
|
||||
assert response.headers["content-type"] == ap.AP_CONTENT_TYPE
|
||||
assert response.json()["id"].endswith("/following")
|
||||
|
||||
|
||||
def test_following__html(client, db) -> None:
|
||||
response = client.get("/following")
|
||||
assert response.status_code == 200
|
||||
assert response.headers["content-type"].startswith("text/html")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue