Initial Commit: Status Testing
This commit is contained in:
1 parent
1eff675f05
commit
42dd1f2d4a
286 files changed
+64800
-369
No files matched your search
@@ -0,0 +1,51 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""Teilnehmer-Name und Namen der Eingetragenen bei Teilnahme-Feldern (CI)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
|
||||
pytest.importorskip("fastapi")
|
||||
|
||||
from helpers import new_client
|
||||
from test_forms import add_question, creator, fill, participant, question_ids, save_settings
|
||||
from test_phase5 import slot_form
|
||||
|
||||
pytestmark = pytest.mark.db
|
||||
|
||||
|
||||
def setup_form(app: Any, names: str) -> tuple[Any, str, str, int, int, str]:
|
||||
carla = creator(app)
|
||||
pid, token, slot_q, (early, _) = slot_form(carla, capacity="", slot_names=names)
|
||||
add_question(carla, pid, "participant_name", label="Ihr Name", email_mode="optional",
|
||||
personal="on")
|
||||
name_q = question_ids(pid)[-1]
|
||||
return carla, pid, token, slot_q, name_q, early
|
||||
|
||||
|
||||
def test_names_of_others_are_shown_when_the_form_says_so(app: Any) -> None:
|
||||
carla, pid, token, slot_q, name_q, early = setup_form(app, "short")
|
||||
guest = new_client(app)
|
||||
missing = fill(guest, token, {f"q{slot_q}": early})
|
||||
assert missing.status_code == 400 and "first and last name" in missing.text
|
||||
assert fill(guest, token, {f"q{slot_q}": early, f"q{name_q}_first": "Bernd",
|
||||
f"q{name_q}_last": "Krause"}).status_code == 303
|
||||
# Angemeldete ohne Namensfeld-Antwort erscheinen mit dem Kontonamen
|
||||
paul = participant(app)
|
||||
page = paul.get(f"/f/{token}").text
|
||||
assert "Bernd K." in page and "Krause" not in page
|
||||
assert "sees who has already signed up" in page
|
||||
# Das Namensfeld ist aus dem Konto vorbelegt
|
||||
assert 'autocomplete="email" value="paul@example.de"' in page
|
||||
assert save_settings(carla, pid, access="link", slot_names="full").status_code == 303
|
||||
assert "Bernd Krause" in new_client(app).get(f"/f/{token}").text
|
||||
|
||||
|
||||
def test_names_stay_hidden_by_default(app: Any) -> None:
|
||||
_, _, token, slot_q, name_q, early = setup_form(app, "off")
|
||||
fill(new_client(app), token, {f"q{slot_q}": early, f"q{name_q}_first": "Bernd",
|
||||
f"q{name_q}_last": "Krause"})
|
||||
page = new_client(app).get(f"/f/{token}").text
|
||||
assert "Bernd" not in page and "sees who has already signed up" not in page
|
||||
Reference in new issue
Block a user