Beispiel #1
0
    def test_add_item(self):
        matrix = TodoMatrix()
        title = 'test add_item function'
        date_urgent = datetime(2017, 6, 6)
        date_not_urgent = datetime(2017, 7, 24)

        matrix.add_item(title, date_urgent, True)
        matrix.add_item(title, date_urgent, False)
        matrix.add_item(title, date_not_urgent, True)
        matrix.add_item(title, date_not_urgent, False)

        self.assertEqual(matrix.todo_quarters['IU'].todo_items[0].title,
                         'test add_item function')
        self.assertEqual(matrix.todo_quarters['IN'].todo_items[0].title,
                         'test add_item function')
        self.assertEqual(matrix.todo_quarters['NU'].todo_items[0].title,
                         'test add_item function')
        self.assertEqual(matrix.todo_quarters['NN'].todo_items[0].title,
                         'test add_item function')
Beispiel #2
0
    def run(self):
        os.system('clear')
        matrix = TodoMatrix()
        matrix.add_items_from_file('todo.csv')

        while self.is_running:
            os.system('clear')
            print(matrix)
            self.display_menu()
            option = self.get_input('Enter choice of menu: ')

            if option == '1':
                title = self.get_input('Enter title of TODO item: ')
                deadline_year = self.get_input('Enter year of deadline: ')
                deadline_month = self.get_input('Enter month of deadline: ')
                deadline_day = self.get_input('Enter day of deadline: ')
                deadline = datetime(int(deadline_year), int(deadline_month),
                                    int(deadline_day))
                is_important = self.get_input(
                    'Is the task important? True/False: ')
                if is_important == 'True':
                    is_important = True
                elif is_important == 'False':
                    is_important = False
                matrix.add_item(title, deadline, is_important)

            elif option == '2':
                quarter_choice = self.get_input(
                    'Choose quarter (IU/IN/NU/NN): ')
                item_choice = int(
                    self.get_input(
                        'Choose number of item to mark as done: ')) - 1
                quarter = matrix.todo_quarters[quarter_choice]
                item = quarter.todo_items[item_choice]
                item.mark()

            elif option == '3':
                quarter_choice = self.get_input(
                    'Choose quarter (IU/IN/NU/NN): ')
                item_choice = int(
                    self.get_input(
                        'Choose number of item to unmark from done: ')) - 1
                quarter = matrix.todo_quarters[quarter_choice]
                item = quarter.todo_items[item_choice]
                item.unmark()

            elif option == '4':
                quarter_choice = self.get_input(
                    'Choose quarter (IU/IN/NU/NN): ')
                item_choice = int(
                    self.get_input('Choose number of item to remove: ')) - 1
                quarter = matrix.todo_quarters[quarter_choice]
                quarter.remove_item(item_choice)
                # item = quarter.todo_items[item_choice]
                # item.unmark()

            elif option == '5':
                matrix.archive_items()

            elif option == '0':
                self.is_running = False

        matrix.archive_items()
        matrix.save_items_to_file('todo.csv')
Beispiel #3
0
 def test_add_item_error(self):
     matrix = TodoMatrix()
     with self.assertRaises(TypeError, msg='Incorrect deadline'):
         matrix.add_item('test error', 'error date')