예제 #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 menu():
    '''
    Display menu and user choice option to turn. 

    Return:
        None
    '''

    info = 'Welcome in Eisenhower matrix. What can I help you?'
    print(info)

    show_menu = '''
    1) choose a status and show TODO items
    2) add new item with deadline and priority
    3) mark TODO item by cross if it's done
    4) undo marking a TODO item
    5) remove a chosen TODO item

    0) archive, save and exit
    '''
    matrix = TodoMatrix()
    start = True
    while start is True:
        print(show_menu)

        user_option = input('Your choice: ')

        if user_option == '1':
            status = choose_status()
            print(matrix.get_quarter(status))

        elif user_option == '2':
            add_new_item(matrix)

        elif user_option == '3':
            status = choose_status()
            quarter = matrix.get_quarter(status)
            mark_done(quarter)

        elif user_option == '4':
            status = choose_status()
            quarter = matrix.get_quarter(status)
            unmark_done(quarter)

        elif user_option == '5':
            status = choose_status()
            quarter = matrix.get_quarter(status)
            remove_item(quarter)

        elif user_option == '0':
            matrix.archive_items()
            save_todo(matrix)
            print('Good bye')
            start = False
            return start

        else:
            print('Error choice!')
예제 #3
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')
예제 #4
0
 def test_constructor(self):
     matrix = TodoMatrix()
     self.assertEqual('IU' in matrix.todo_quarters.keys(), True)
     self.assertEqual('IN' in matrix.todo_quarters.keys(), True)
     self.assertEqual('NU' in matrix.todo_quarters.keys(), True)
     self.assertEqual('NN' in matrix.todo_quarters.keys(), True)
     self.assertEqual(len(matrix.todo_quarters.keys()), 4)
예제 #5
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!')
예제 #6
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__())
예제 #7
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')
예제 #8
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')
예제 #9
0
 def test_add_item_error(self):
     matrix = TodoMatrix()
     with self.assertRaises(TypeError, msg='Incorrect deadline'):
         matrix.add_item('test error', 'error date')
예제 #10
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')
예제 #11
0
 def test_constructor(self):
     matrix = TodoMatrix()
     self.assertEqual(tuple(matrix.todo_quarters), ('IU', 'IN', 'NU', 'NN'))
예제 #12
0
def main():
    quarter = TodoQuarter()
    matrix = TodoMatrix()
    menu(matrix, quarter)