Ejemplo n.º 1
0
    def test_delete_task(self, mock_stdout):
        main_menu = MainMenu()
        test_name = "John Doe"
        task_title = "Testing Task To be deleted"
        task_timespent = "1"
        task_notes = "to be deleted"
        datestr = "07/04/1776"

        prompts = [
            test_name, datestr, task_title, task_timespent, task_notes, 'y',
            'q'
        ]
        with mock.patch('builtins.input', side_effect=prompts):
            main_menu.add_task()

        task_search = TaskSearch()
        prompts = ["07/04/1776", 'd', 'y', 'q', 'q']
        with mock.patch('builtins.input', side_effect=prompts):
            task_search.search_by_taskdate()

        sdate = convertdate("07/04/1976")
        tasks = Task.select().where(
                      Task.timestamp.year == sdate.year \
                      and Task.timestamp.month == sdate.month \
                      and Task.timestamp.day == sdate.day)

        self.assertEquals(len(tasks), 0)
Ejemplo n.º 2
0
    def test_add_task(self, mock_stdout):
        # Test adding task with a date provided
        main_menu = MainMenu()
        test_name = "John Doe"
        task_title = "Testing Task Title2"
        task_timespent = "30"
        task_notes = "coding!"
        datestr = "03/18/1981"

        prompts = [
            test_name, datestr, task_title, task_timespent, task_notes, 'y',
            'q'
        ]
        with mock.patch('builtins.input', side_effect=prompts):
            added_successfully = main_menu.add_task()
        self.assertTrue(added_successfully)

        # test adding task without date
        task_title = "Testing Task Title3"
        prompts = [
            test_name, "", task_title, task_timespent, task_notes, 'y', 'q'
        ]
        with mock.patch('builtins.input', side_effect=prompts):
            added_successfully = main_menu.add_task()
        self.assertTrue(added_successfully)
Ejemplo n.º 3
0
    def test_add_task_employee_not_found(self, mock_stdout):
        main_menu = MainMenu()
        test_name = "Employee Notfound"
        task_title = "Testing Task Title"
        task_timespent = "30"
        task_notes = "Testing out code"

        prompts = [
            test_name, " ", task_title, task_timespent, task_notes, 'y', 'q'
        ]
        with mock.patch('builtins.input', side_effect=prompts):
            added_successfully = main_menu.add_task()
        self.assertFalse(added_successfully)