Example #1
0
 def test_get_unique_employees(self):
     expected = ['Terry', 'Chris', 'Ben']
     entries = [Entry(employee='Terry'),
                Entry(employee='Chris'),
                Entry(employee='Ben')]
     actual = worklog.get_unique_employees(entries)
     self.assertEqual(actual, expected)
Example #2
0
    def test_delete_entry(self):
        entries = Entry.select()
        index = 0

        with mock.patch('builtins.input', side_effect=["y", ""]):
            worklog.delete_task(index, entries)
            self.assertEqual(Entry.select().count(), 1)
Example #3
0
 def test_get_unique_dates(self):
     expected = ['24-08-1992', '24-09-1996', '01-01-2001']
     entries = [Entry(date=datetime.datetime.strptime("24-08-1992",
                                                      worklog.DATE_FORMAT)),
                Entry(date=datetime.datetime.strptime("24-09-1996",
                                                      worklog.DATE_FORMAT)),
                Entry(date=datetime.datetime.strptime("01-01-2001",
                                                      worklog.DATE_FORMAT))]
     actual = worklog.get_unique_dates(entries)
     self.assertEqual(actual, expected)
Example #4
0
    def setUp(self):
        test_db.bind(MODELS, bind_refs=False, bind_backrefs=False)
        test_db.connect()
        test_db.create_tables(MODELS)

        Entry.create(task=test_entry['task'],
                     date=test_entry['date'],
                     employee=test_entry['employee'],
                     duration=test_entry['duration'],
                     notes=test_entry['notes'])

        Entry.create(task=test_entry_2['task'],
                     date=test_entry_2['date'],
                     employee=test_entry_2['employee'],
                     duration=test_entry_2['duration'],
                     notes=test_entry_2['notes'])
Example #5
0
 def test_search_by_date_range(self):
     expected = 1
     entries = Entry.select()
     with unittest.mock.patch('builtins.input',
                              side_effect=["24-08-1991", "24-08-1997"]):
         actual = worklog.search_by_date_range(entries)
         self.assertEqual(len(actual), expected)
Example #6
0
 def test_search_by_employee(self):
     expected = 1
     entries = Entry.select()
     with unittest.mock.patch('builtins.input',
                              side_effect=["Ben Employee test"]):
         actual = worklog.search_by_employee(entries)
         self.assertEqual(actual.select().count(), expected)
Example #7
0
 def test_view_all_tasks(self):
     expected = 2
     entries = Entry.select()
     with unittest.mock.patch('builtins.input', side_effect=[""]):
         actual = worklog.view_all_tasks(entries)
         self.assertEqual(len(actual), expected)
Example #8
0
 def test_search_by_duration(self):
     expected = 1
     entries = Entry.select()
     with unittest.mock.patch('builtins.input', side_effect=["20"]):
         actual = worklog.search_by_time_spent(entries)
         self.assertEqual(len(actual), expected)