-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtasktracker_test.py
More file actions
26 lines (22 loc) · 1019 Bytes
/
tasktracker_test.py
File metadata and controls
26 lines (22 loc) · 1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from tasktracker import TaskTracker
import unittest
from datetime import date
class TestTaskTracker(unittest.TestCase):
def setUp(self):
self.tracker = TaskTracker(":memory:", "tasks")
self.tracker.check()
def test_add_and_list_task(self):
self.tracker.add("Test Task 1")
self.tracker.add("Test Task 2", due_date=date(2024, 12, 31).isoformat())
tasks = self.tracker.list_task()
self.assertEqual(len(tasks), 2)
self.assertIn(("Test Task 1", date.today().isoformat(), 0), tasks)
self.assertIn(("Test Task 2", date(2024, 12, 31).isoformat(), 0), tasks)
def test_check_creates_table(self):
# The check method should create the table if it doesn't exist
result = self.tracker.check()
self.assertTrue(result)
# Verify that the table exists by adding a task
self.tracker.add("Test Task 3")
tasks = self.tracker.list_task()
self.assertIn(("Test Task 3", date.today().isoformat(), 0), tasks)