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)
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)
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)
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'])
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)
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)
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)
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)