예제 #1
0
def start_module():
    """
    Starts this module and displays its menu.
    User can access default special features from here.
    User can go back to main menu from here.

    Returns:
        None
    """
    menu = [
        'Show items by status', 'Add item', 'Enter task toggle mode',
        'Remove task', 'Archive Tasks', 'show eisenhower table'
    ]
    user_input = None
    matrix = TodoMatrix()
    try:
        matrix.add_items_from_file('my_file.csv')
    except FileNotFoundError:
        print("Error: file with data no provided.")
        open('my_file.csv', 'w').close()

    while user_input != '0':
        handle_menu(menu)
        user_input = choose_option(matrix)

    matrix.archive_items()
    matrix.save_items_to_file('my_file.csv')
예제 #2
0
    def test_add_items_from_file(self):
        matrix = TodoMatrix()
        matrix.add_items_from_file('todo_items_read_test.csv')

        self.assertEqual(
            matrix.todo_quarters['IU'].__str__(),
            '1. [ ] 5-6 make a coffee\n2. [ ] 6-6 read about OOP\n')
        self.assertEqual(
            matrix.todo_quarters['IN'].__str__(),
            '1. [ ] 30-6 give mentors a feedback\n2. [ ] 23-10 go to the doctor\n'
        )
        self.assertEqual(matrix.todo_quarters['NU'].__str__(),
                         '1. [ ] 7-6 start coding\n')
        self.assertEqual(
            matrix.todo_quarters['NN'].__str__(),
            '1. [ ] 28-6 buy flowers\n2. [ ] 15-7 cook a dinner\n')
예제 #3
0
def main():
    os.system('clear')
    print('Welcome to Eisenhower Matrix!\n')
    matrix = TodoMatrix()

    try:
        matrix.add_items_from_file('todo_items.csv')
    except FileNotFoundError:
        common.print_error_message(
            'Database file not found! No items were imported')

    exit = False
    while not exit:
        print(matrix)
        handle_menu()
        exit = choose_and_start_option(matrix)

    print('Thank you for using Eisenhower Matrix. See you next time!')
예제 #4
0
    def test_save_items_to_file(self):
        matrix_expected = TodoMatrix()
        matrix_expected.add_items_from_file('todo_items_read_test.csv')
        matrix_expected.save_items_to_file('todo_items_save_test.csv')

        matrix_tested = TodoMatrix()
        matrix_tested.add_items_from_file('todo_items_save_test.csv')

        self.assertEqual(matrix_tested.todo_quarters['IU'].__str__(),
                         matrix_expected.todo_quarters['IU'].__str__())

        self.assertEqual(matrix_tested.todo_quarters['IN'].__str__(),
                         matrix_expected.todo_quarters['IN'].__str__())

        self.assertEqual(matrix_tested.todo_quarters['NU'].__str__(),
                         matrix_expected.todo_quarters['NU'].__str__())

        self.assertEqual(matrix_tested.todo_quarters['NN'].__str__(),
                         matrix_expected.todo_quarters['NN'].__str__())
예제 #5
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')
예제 #6
0
 def test_file_error(self):
     matrix = TodoMatrix()
     with self.assertRaises(FileNotFoundError,
                            msg='Problem with open a file'):
         matrix.add_items_from_file('no_file.csv')