예제 #1
0
        check[0].completed = True
        return f"Completed task {task_name}"

    def clean_section(self):
        removed_tasks = [t for t in self.tasks if t.completed]
        for c in removed_tasks:
            self.tasks.remove(c)
        return f"Cleared {len(removed_tasks)} tasks."

    def view_section(self):
        data = f"Section {self.name}:\n"
        for t in self.tasks:
            data += f"{t.details()}\n"
        return data


if __name__ == '__main__':
    task = Task("Make bed", "27/05/2020")
    print(task.change_name("Go to University"))
    print(task.change_due_date("28.05.2020"))
    task.add_comment("Don't forget laptop")
    print(task.edit_comment(0, "Don't forget laptop and notebook"))
    print(task.details())
    section = Section("Daily tasks")
    print(section.add_task(task))
    section.complete_task('Go to University')
    second_task = Task("Make bed", "27/05/2020")
    section.add_task(second_task)
    print(section.clean_section())
    print(section.view_section())
예제 #2
0
 def test_edit_comment_working(self):
     task = Task("Tst", "27.04.2020")
     task.add_comment("pay the bills")
     message = task.edit_comment(0, "finish my homework")
     expected = "finish my homework"
     self.assertEqual(message, expected)
예제 #3
0
 def test_edit_comment_not_found(self):
     task = Task("Tst", "27.04.2020")
     task.add_comment("pay the bills")
     message = task.edit_comment(1, "finish my homework")
     expected = "Cannot find comment."
     self.assertEqual(message, expected)
예제 #4
0
from project.section import Section
from project.task import Task

if __name__ == '__main__':
    task = Task("Make bed", "27/05/2020")
    print(task.change_name("Go to University"))
    print(task.change_due_date("28.05.2020"))
    task.add_comment("[finish my homework, pay the bills]")
    task.add_comment("[finish my homework, pay the bills]")
    task.add_comment("[finish my homework, pay the bills]")
    print(task.edit_comment(0, "[finish my homework]"))
    print(task.edit_comment(1, "[pay the bills]"))
    print(task.edit_comment(2, "[finish my homework]"))
    print(task.details())
    section = Section("Daily tasks")
    print(section.add_task(task))
    second_task = Task("Make bed", "27/05/2020")
    section.add_task(second_task)
    print(section.clean_section)
    print(section.view_section())

# [print({key}:{value} for key, value in dict.items()]