Build out all 27 modules + capstone (#1)
Co-authored-by: claude <claude@jpaul.io> Co-committed-by: claude <claude@jpaul.io>
This commit was merged in pull request #1.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
"""Tests for the tasks-app core logic — the kind of suite Module 13 has you write.
|
||||
|
||||
Reproduced here so this module's lab is self-contained: if you already wrote tests in Module 13,
|
||||
use those instead. Run locally with `pytest -q` from the project folder. CI runs exactly this.
|
||||
"""
|
||||
|
||||
from tasks import TaskList
|
||||
|
||||
|
||||
def test_add_appends_a_task():
|
||||
tl = TaskList()
|
||||
tl.add("write the CI lesson")
|
||||
assert len(tl.tasks) == 1
|
||||
assert tl.tasks[0].title == "write the CI lesson"
|
||||
assert tl.tasks[0].done is False
|
||||
|
||||
|
||||
def test_complete_marks_a_task_done():
|
||||
tl = TaskList()
|
||||
tl.add("ship it")
|
||||
tl.complete(0)
|
||||
assert tl.tasks[0].done is True
|
||||
|
||||
|
||||
def test_pending_excludes_completed_tasks():
|
||||
tl = TaskList()
|
||||
tl.add("a")
|
||||
tl.add("b")
|
||||
tl.complete(0)
|
||||
pending = tl.pending()
|
||||
assert len(pending) == 1
|
||||
assert pending[0].title == "b"
|
||||
|
||||
|
||||
def test_render_is_friendly_when_empty():
|
||||
assert TaskList().render() == "(no tasks yet)"
|
||||
Reference in New Issue
Block a user