def test_edit_entry_notes(self, mock_input, mock_stdout): with test_database(test_db, [Task]): Task.create( employee='Saki', name='Bowling', date=datetime.date(2017, 8, 22), time='45', notes='Strike' ) query = Task.get(Task.id == 1) work_db.edit_entry(query) self.assertEqual(Task.get(Task.id == 1).notes, 'P-league') self.assertIn('Entry edited', mock_stdout.getvalue())
def test_edit_entry_date(self, mock_input, mock_stdout): with test_database(test_db, [Task]): Task.create( employee='Saki', name='Bowling', date=datetime.date(2017, 8, 22), time='45', notes='Strike' ) query = Task.get(Task.id == 1) work_db.edit_entry(query) self.assertIn("Dates should be valid and in format YYYY-MM-DD", mock_stdout.getvalue()) self.assertEqual(Task.get(Task.id == 1).date, datetime.date(2017, 8, 21)) self.assertIn('Entry edited', mock_stdout.getvalue())
def test_delete_entry_confirm(self, mock_input, mock_stdout): with test_database(test_db, [Task]): Task.create( employee='Kashiyuka', name='Singing', date=datetime.date(2017, 8, 22), time='5', notes='Autotune' ) query = Task.get(Task.id == 1) work_db.delete_entry(query) self.assertEqual(Task.select().count(), 0) self.assertIn('Entry deleted', mock_stdout.getvalue())