Files
ai-workflow-course/modules/21-skills-teaching-the-ai-your-playbook/lab/start/test_tasks.py
T
claude 95e5911957
CI / check (push) Successful in 7s
Sync course wiki / sync-wiki (push) Successful in 4s
Use python3 as the canonical command name course-wide (#104) (#105)
2026-06-23 20:25:05 -04:00

45 lines
1.1 KiB
Python

"""Test suite for the tasks-app. Run from this folder with:
python3 -m unittest
Your "add a command" skill should ADD a test here for every new command. The point is to assert
intended behavior, not just that nothing crashed.
"""
import unittest
from tasks import TaskList
class TestTaskBasics(unittest.TestCase):
def test_add_appends_a_task(self):
tl = TaskList()
tl.add("write the skill")
self.assertEqual(len(tl.tasks), 1)
self.assertEqual(tl.tasks[0].title, "write the skill")
self.assertFalse(tl.tasks[0].done)
def test_complete_marks_done(self):
tl = TaskList()
tl.add("a")
tl.complete(0)
self.assertTrue(tl.tasks[0].done)
def test_pending_excludes_completed(self):
tl = TaskList()
tl.add("a")
tl.add("b")
tl.complete(0)
self.assertEqual([t.title for t in tl.pending()], ["b"])
def test_pending_count_ignores_done(self):
tl = TaskList()
tl.add("a")
tl.add("b")
tl.complete(0)
self.assertEqual(tl.pending_count(), 1)
if __name__ == "__main__":
unittest.main()