Files
devplacepy/tests/api/proxy.py
T

44 lines
1.2 KiB
Python
Raw Normal View History

# retoor <retoor@molodetz.nl>
import time
import pytest
import requests
from devplacepy.database import set_setting
from tests.conftest import BASE_URL, CACHE_VERSION_PROPAGATION_SECONDS
@pytest.fixture(scope="module", autouse=True)
def _disable_happy_404(app_server):
set_setting("happy_404_enabled", "0")
time.sleep(CACHE_VERSION_PROPAGATION_SECONDS)
yield
set_setting("happy_404_enabled", "1")
time.sleep(CACHE_VERSION_PROPAGATION_SECONDS)
def test_proxy_unknown_slug_returns_404(app_server):
r = requests.get(f"{BASE_URL}/p/nonexistent-slug", allow_redirects=False)
assert r.status_code == 404
def test_proxy_unknown_slug_json(app_server):
r = requests.get(
f"{BASE_URL}/p/nonexistent-slug",
headers={"X-Requested-With": "fetch"},
allow_redirects=False,
)
assert r.status_code == 404
def test_proxy_unknown_slug_with_path(app_server):
r = requests.get(
f"{BASE_URL}/p/nonexistent-slug/some/path", allow_redirects=False
)
assert r.status_code == 404
def test_proxy_post_unknown_slug(app_server):
r = requests.post(f"{BASE_URL}/p/nonexistent-slug", allow_redirects=False)
assert r.status_code == 404