Mirror test layout, domcontentloaded waits, backup DB writes outside threads
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
JSON = {"Accept": "application/json"}
|
||||
|
||||
|
||||
def test_join_request_is_stored_and_visible_to_admin(anon, admin):
|
||||
response = anon.post("/binnen", data={"name": "Schrijver Een", "contact": "schrijver@example.invalid", "repo_url": "https://example.com/repo", "message": "Ik wil meeschrijven.", "website": ""})
|
||||
assert response.status_code in (302, 303)
|
||||
assert "ok=1" in response.headers["location"]
|
||||
rows = admin.get("/admin/joins", headers=JSON).json()["requests"]
|
||||
row = next(row for row in rows if row["name"] == "Schrijver Een")
|
||||
assert row["contact"] == "schrijver@example.invalid"
|
||||
assert row["repo_url"].startswith("https://example.com/repo")
|
||||
status = admin.post(f"/admin/joins/{row['uid']}/status", json={"status": "contacted"}, headers=JSON)
|
||||
assert status.status_code == 200
|
||||
|
||||
|
||||
def test_join_json_api(anon):
|
||||
response = anon.post("/binnen", json={"name": "Schrijver Twee", "contact": "@twee"}, headers=JSON)
|
||||
assert response.status_code == 200
|
||||
assert response.json()["ok"] is True
|
||||
|
||||
|
||||
def test_honeypot_is_not_stored(anon, admin):
|
||||
anon.post("/binnen", data={"name": "Robot Bot", "contact": "bot@example.invalid", "website": "spam"})
|
||||
rows = admin.get("/admin/joins", headers=JSON).json()["requests"]
|
||||
assert not any(row["name"] == "Robot Bot" for row in rows)
|
||||
|
||||
|
||||
def test_join_validation(anon):
|
||||
response = anon.post("/binnen", json={"name": "x", "contact": ""}, headers=JSON)
|
||||
assert response.status_code == 422
|
||||
|
||||
|
||||
def test_member_cannot_view_joins(member):
|
||||
assert member.get("/admin/joins", headers=JSON).status_code == 403
|
||||
Reference in New Issue
Block a user