22 lines
751 B
Python
22 lines
751 B
Python
from app.validation import normalize_status, validate_todo_fields
|
|
|
|
def test_normalize_status_accepts_allowed():
|
|
assert normalize_status("done") == "done"
|
|
assert normalize_status("in-progress") == "in-progress"
|
|
|
|
def test_normalize_status_defaults_on_invalid():
|
|
assert normalize_status("weird") == "not-started"
|
|
assert normalize_status("") == "not-started"
|
|
assert normalize_status(None) == "not-started"
|
|
|
|
def test_validate_todo_fields_ok():
|
|
ok, errors = validate_todo_fields("A", "B")
|
|
assert ok is True
|
|
assert errors == []
|
|
|
|
def test_validate_todo_fields_missing_both():
|
|
ok, errors = validate_todo_fields("", "")
|
|
assert ok is False
|
|
assert "title_required" in errors
|
|
assert "description_required" in errors
|