forked from retoor/devplacepy
chore: reorganize test files into domain-specific subdirectories under tests/
Split the monolithic test directory into three tiers (unit, api, e2e) with a path-mirroring directory structure. Added corresponding Makefile targets (test-unit, test-api, test-e2e) and updated all documentation references (CLAUDE.md, README.md, testing-cicd.html, testing-framework.html, testing-make.html) to reflect the new layout and naming conventions.
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
import uuid
|
||||
import requests
|
||||
from tests.conftest import BASE_URL
|
||||
def _session_push():
|
||||
s = requests.Session()
|
||||
name = f"push_{uuid.uuid4().hex[:10]}"
|
||||
s.post(
|
||||
f"{BASE_URL}/auth/signup",
|
||||
data={
|
||||
"username": name,
|
||||
"email": f"{name}@test.dev",
|
||||
"password": "secret123",
|
||||
"confirm_password": "secret123",
|
||||
},
|
||||
allow_redirects=True,
|
||||
)
|
||||
return s
|
||||
|
||||
|
||||
def test_public_key_endpoint(app_server):
|
||||
r = requests.get(f"{BASE_URL}/push.json")
|
||||
assert r.status_code == 200
|
||||
assert r.json().get("publicKey")
|
||||
|
||||
|
||||
def test_register_requires_auth(app_server):
|
||||
r = requests.post(
|
||||
f"{BASE_URL}/push.json",
|
||||
json={
|
||||
"endpoint": "https://push.example.com/anon",
|
||||
"keys": {"p256dh": "key", "auth": "auth"},
|
||||
},
|
||||
allow_redirects=False,
|
||||
)
|
||||
assert r.status_code == 401
|
||||
|
||||
|
||||
def test_register_success(app_server):
|
||||
s = _session_push()
|
||||
r = s.post(
|
||||
f"{BASE_URL}/push.json",
|
||||
json={
|
||||
"endpoint": "https://push.example.com/sub-1",
|
||||
"keys": {"p256dh": "p256dh_fake", "auth": "auth_fake"},
|
||||
},
|
||||
)
|
||||
assert r.status_code == 200, r.text
|
||||
assert r.json().get("registered") is True
|
||||
|
||||
|
||||
def test_register_missing_keys_rejected(app_server):
|
||||
s = _session_push()
|
||||
r = s.post(f"{BASE_URL}/push.json", json={"endpoint": "https://push.example.com/x"})
|
||||
assert r.status_code == 400
|
||||
|
||||
|
||||
def test_register_invalid_json_rejected(app_server):
|
||||
s = _session_push()
|
||||
r = s.post(
|
||||
f"{BASE_URL}/push.json",
|
||||
data="not-json",
|
||||
headers={"Content-Type": "application/json"},
|
||||
)
|
||||
assert r.status_code == 400
|
||||
Reference in New Issue
Block a user