コード例 #1
0
 def test_set_status(self):
     t = Task()
     t.status = TaskStatus.DOING
     self.assertEqual(t.status, TaskStatus.DOING)
     t.status = TaskStatus.TODO
     self.assertEqual(t.status, TaskStatus.TODO)
     t.status = TaskStatus.DONE
     self.assertEqual(t.status, TaskStatus.DONE)
コード例 #2
0
 def add_empty_task(self):
     m = Model()
     self.assertEqual(m.add_empty_task(), 0)
     m.add_empty_task()
     m.add_empty_task()
     m.add_empty_task()
     self.assertEqual(m.add_empty_task(), 4)
     t = Task()
     t.id = 5
     m.add_task(t)
     t.id = 6
     m.add_task(t)
     self.assertEqual(m.add_empty_task(), 7)
コード例 #3
0
    def test_save_load_tasks(self):
        m = Model()

        t = Task()
        m.add_task(t)
        m.add_task(t)
        m.add_task(t)
        m.add_task(t)
        m.add_task(t)
        m.settings['db_path'] = "test_db.txt"

        m.save_tasks()
        m2 = Model()
        m2.settings['db_path'] = "test_db.txt"
        m2.load_tasks()
        self.assertEqual(m.tasks, m2.tasks)
コード例 #4
0
    def find_free_id(self):
        m = Model()
        t = Task()
        t.id = 1
        m.add_task(t)
        t.id = 3
        m.add_task(t)
        t.id = 6
        m.add_task(t)
        t.id = 9
        m.add_task(t)

        self.assertEqual(m.find_free_id(), 0)

        t.id = 0
        m.add_task(t)
        self.assertEqual(m.find_free_id(), 2)
コード例 #5
0
    def test_get_task_index(self):
        m = Model()

        t1 = Task()
        t1.set_content("test content")
        t1.set_status(TaskStatus.DONE)
        t1.id = 5
        m.add_task(t1)

        t2 = Task()
        t2.set_content("test content2")
        t2.set_status(TaskStatus.DOING)
        t2.id = 7
        m.add_task(t2)

        self.assertEqual(m.get_task_index(t2), 1)
        self.assertEqual(m.get_task_index(t1), 0)
コード例 #6
0
    def test_del_task(self):
        m = Model()
        t = Task()

        t.set_content("test content")
        t.set_status(TaskStatus.DONE)
        t.id = 5
        m.add_task(t)

        t.set_content("test content2")
        t.set_status(TaskStatus.DOING)
        t.id = 11
        m.add_task(t)

        m.del_task(5)
        self.assertEqual(len(m.tasks), 1)

        gt = m.get_task(11)
        self.assertEqual(gt.get_status(), TaskStatus.DOING)
        self.assertEqual(gt.get_content(), "test content2")

        self.assertEqual(m.get_task(5), False)
コード例 #7
0
    def test_add_task(self):
        m = Model()
        t = Task()

        t.set_content("test content")
        t.set_status(TaskStatus.DONE)
        t.id = 5
        m.add_task(t)

        t.set_content("test content2")
        t.set_status(TaskStatus.DOING)
        t.id = 10
        m.add_task(t)

        gt2 = m.get_task(5)
        self.assertEqual(gt2.get_status(), TaskStatus.DONE)
        self.assertEqual(gt2.get_content(), "test content")

        gt = m.get_task(10)
        self.assertEqual(gt.get_status(), TaskStatus.DOING)
        self.assertEqual(gt.get_content(), "test content2")
コード例 #8
0
    def test_get_task(self):
        m = Model()

        t1 = Task()
        t1.set_content("test content")
        t1.set_status(TaskStatus.DONE)
        t1.id = 5
        m.add_task(t1)

        t2 = Task()
        t2.set_content("test content2")
        t2.set_status(TaskStatus.DOING)
        t2.id = 7
        m.add_task(t2)

        gt1 = m.get_task(5)
        gt2 = m.get_task(7)
        self.assertEqual(gt1, t1)
        self.assertEqual(gt2, t2)
コード例 #9
0
 def test_init(self):
     t = Task()
     self.assertEqual(t.id, 0)
     self.assertEqual(t.content, "")
     self.assertEqual(t.status, TaskStatus.TODO)
コード例 #10
0
    def test_eq(self):
        t1 = Task()
        t1.content = "content one"
        t1.status = TaskStatus.TODO
        t1.id = 5

        t2 = Task()
        t2.content = "content one"
        t2.status = TaskStatus.DOING
        t2.id = 7

        self.assertNotEqual(t1, t2)
        t2.id = 5
        self.assertEqual(t1, t2)
コード例 #11
0
 def test_get_content(self):
     t = Task()
     t.content = "test 1 2 3"
     self.assertEqual(t.get_content(), "test 1 2 3")
コード例 #12
0
 def test_set_content(self):
     t = Task()
     t.set_content("new content")
     self.assertEqual(t.content, "new content")
コード例 #13
0
 def test_get_status(self):
     t = Task()
     t.status = TaskStatus.DOING
     self.assertEqual(t.get_status(), TaskStatus.DOING)
コード例 #14
0
 def add_empty_task(self):
     t = Task()
     t.id = self.find_free_id()
     self.tasks.append(t)
     return t.id
コード例 #15
0
from classModel import Model
from classTask import Task, TaskStatus
import debug

t1 = Task()
t1.set_content(
    """Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum""")
t1.set_status(TaskStatus.DONE)
t1.id = 0

t2 = Task()
t2.set_content("""Just as with any string, anything between the starting and
 ending quotes becomes part of the string, so this example has a leading blank
 (as pointed out by @root45). This string will also contain both blanks and
 newlines.""")
t2.set_status(TaskStatus.DOING)
t2.id = 1

t3 = Task()
t3.set_content("""If you don't want a multiline string but just have a long
 single line string, you can use parentheses, just make sure you don't include
 commas between the string segments, then it will be a tuple.""")
t3.set_status(TaskStatus.TODO)
t3.id = 3

t4 = Task()
t4.set_content("""This section often ends up being an exceedingly long and
 detailed list of tasks that is tough to maintain, but even tougher for an
 employee to remember and apply in their day-to-day work.""")