Strengthen test_show_cert_form_confirm to assert result.days

A blank/default days value round-trips as "" even from a reverted
three-field form (CertFormResult.days defaults to ""), so it would not
prove the Days field was traversed. Use a non-blank days="90" instead,
which only survives if the field exists and is validated by _submit().
This commit is contained in:
Vlad Doloman
2026-08-15 05:34:13 +03:00
parent 96664f954c
commit 4af7d67bf3

View File

@@ -116,16 +116,23 @@ def test_show_cert_form_uses_erase_not_clear():
def test_show_cert_form_confirm():
"""Enter advances through the 4 fields to the Continue button; Enter on
Continue confirms. That's 5 Enter keypresses total."""
Continue confirms. That's 5 Enter keypresses total.
days="90" (non-blank) is used deliberately: a blank default would still
read back as "" even from a reverted three-field form (CertFormResult.days
defaults to ""), so it would not actually prove the days field was
traversed. A non-blank value only round-trips if the days field exists,
was reached by the Enter sequence, and was carried into the result."""
stdscr = _make_stdscr()
win = _make_win(rows=20, cols=70)
win.getch.side_effect = [10, 10, 10, 10, 10]
with patch("curses.newwin", return_value=win):
result = show_cert_form(stdscr, cn="bob", email="bob@example.com")
result = show_cert_form(stdscr, cn="bob", email="bob@example.com", days="90")
assert isinstance(result, CertFormResult)
assert result.confirmed is True
assert result.cn == "bob"
assert result.email == "bob@example.com"
assert result.days == "90"
assert len(result.password) > 0