def test_create_todo(): todo.todos = [] todo.create_todo(todo.todos, title="Test title", description="This is a description of test", level="important") assert len(todo.todos) > 0, "Create failed, todos is zero" assert todo.todos[0]["title"] == "Test title" assert (todo.todos[0]["description"] == "This is a description of test") assert todo.todos[0]["level"] == "important" print("Ok-create_todo.")
def test_create_todo(): todo.todos = [] todo.create_todo(todo.todos, title="make some stuff", description="Stuff needs to be programmed", level="Important") assert len(todo.todos) == 1 assert (todo.todos[0]['title'] == "make some stuff") assert (todo.todos[0]['description'] == "Stuff needs to be programmed") assert todo.todos[0]['level'] == "Important" print "ok - create_todo"
def test_create_todo(): # List of to-dos todo.todos = [] # Run small part of program todo.create_todo(todo.todos, title="Make some stuff", description="Stuff needs to be programmed", level="Important") # Test results assert len(todo.todos) == 1, "Todo was not created!" assert todo.todos[0]['title'] == "Make some stuff" assert (todo.todos[0]['description'] == "Stuff needs to be programmed") assert todo.todos[0]['level'] == "IMPORTANT" print "Ok - create_todo"
def test_create_todo(): todo.todos = [] todo.create_todo(todo.todos, title = "Make some stuff", description = "Stuff needs to be programmed", level = "Important") assert len(todo.todos) == 1, "Todo was not created!" assert todo.todos[0]['title'] == "Make some stuff" assert (todo.todos[0]['description'] == "Stuff needs to be programmed") assert todo.todos[0]['level'] == "Important" print "ok - create_todo"
def test_create_todo(): todo.todos = [] todo.create_todo(todo.todos, title="Make some stuff", description="Stuff needs to be programmed", level="Important") assert len(todo.todos) == 1, "Todo was not created!" assert todo.todos[0]['title'] == "Make some stuff" assert todo.todos[0]['description'] == "Stuff needs to be programmed" assert todo.todos[0]['level'] == "IMPORTANT" print "ok - create_todo"
def test_finishTodo(self): todo = todo_module.create_todo('テスト', datetime.now() + timedelta(days=1)) finished_todo, ratio = todo_module.finish_todo(todo) self.assertEqual(ratio, 0) self.assertNotEqual(todo['finish'], finished_todo['finish'])
def test_todo_sort_after_creation(): todo.todos = [ {"title": "test unimportant title", "description": "test unimportant description", "level": "unimportant"}, {"title": "title medium title", "description": "test medium description", "level": "medium"}, ] todo.create_todo(todo.todos, title="test Important test", description="test important description", level="important") assert todo.todos[0]["level"] == "important" assert todo.todos[1]["level"] == "medium" assert todo.todos[2]["level"] == "unimportant" print("Ok-sort_after_creation")
def test_editDeadline(self): todo = todo_module.create_todo('テスト', datetime.now() + timedelta(days=1)) edited_todo = todo_module.edit_deadline( todo, datetime.now() + timedelta(days=2)) self.assertNotEqual(todo['deadline'], edited_todo['deadline'])
def test_createTodo(self): content = 'テスト' deadline = datetime.now() + timedelta(days=1) todo = todo_module.create_todo(content, deadline) self.assertEqual(todo['content'], content) self.assertEqual(todo['deadline'], deadline)
def test_addTag(self): todo = todo_module.create_todo('テスト', datetime.now() + timedelta(days=1)) temp_todo = todo_module.add_tag(todo, 'プライベート') edited_todo = todo_module.add_tag(temp_todo, '仕事用') self.assertIn('プライベート', edited_todo['tags']) self.assertIn('仕事用', edited_todo['tags']) self.assertNotEqual(todo['tags'], edited_todo['tags'])
def test_removeTag(self): todo = todo_module.create_todo('テスト', datetime.now() + timedelta(days=1)) temp_todo_0 = todo_module.add_tag(todo, 'プライベート') temp_todo_1 = todo_module.add_tag(temp_todo_0, '仕事用') edited_todo = todo_module.remove_tag(temp_todo_1, 'プライベート') self.assertNotIn('プライベート', edited_todo['tags']) self.assertIn('仕事用', edited_todo['tags'])
def test_todo_sort_after_creation(): todo.todos = [ { "title": "test unimportant title", "description": "test unimportant description", "level": "unimportant" }, { "title": "title medium title", "description": "test medium description", "level": "medium" }, ] todo.create_todo(todo.todos, title="test Important test", description="test important description", level="important") assert todo.todos[0]["level"] == "important" assert todo.todos[1]["level"] == "medium" assert todo.todos[2]["level"] == "unimportant" print("Ok-sort_after_creation")
def test_todo_sort_after_creation(): todo.todos = [ { 'title': 'test unimportant todo', 'description': 'This is an unimportant test', 'level': 'Unimportant' }, { 'title': 'test medium todo', 'description': 'This is a test', 'level': 'Medium' } ] # Create another to-do todo.create_todo(todo.todos, title="Make some stuff", description = "Stuff needs to be programmed", level = "Important") # Check to-do order assert todo.todos[0]['level'] == "IMPORTANT" assert todo.todos[1]['level'] == "Medium" assert todo.todos[2]['level'] == "Unimportant" print "OK - todo sort after creation"
def test_todo_sort_after_creation(): todo.todos = [ { 'title' : 'test unimportant todo', 'description' : 'This is an unimportant test', 'level' : 'Unimportant' }, { 'title' : 'test medium todo', 'description' : 'This is a test', 'level' : 'Medium' }, ] todo.create_todo(todo.todos, title="Make some stuff", description="Stuff needs to be programmed", level="Important") assert todo.todos[0]['level'] == "IMPORTANT" assert todo.todos[1]['level'] == "Medium" assert todo.todos[2]['level'] == "Unimportant" print "ok - todo sort after creation"
def test_todo_sort_after_creation(): todo.todos = [ { 'title': 'test unimportant todo', 'description': 'An unimportant test', 'level': 'Unimportant' }, { 'title': 'test medium todo', 'description': 'A test', 'level': 'Medium' }, ] todo.create_todo(todo.todos, title="Make some stuff", description="Stuff needs to be programmed", level="Important") assert todo.todos[0]['level'] == "IMPORTANT" assert todo.todos[1]['level'] == "Medium" assert todo.todos[2]['level'] == "Unimportant" print "ok - todo sort after creation"
def test_removeTagRaisesTagNotFoundError(self): with self.assertRaises(Exception): todo = todo_module.create_todo('テスト', datetime.now() + timedelta(days=1)) added_todo = todo_module.add_tag(todo, 'プライベート') edited_todo = todo_module.remove_tag(added_todo, '仕事')
def create_todo(self, content: str, deadline: date) -> Todo: todo = create_todo(content, deadline) self._todos.append(todo) return todo
def test_addTagRaisesEmptyTagError(self): with self.assertRaises(Exception): todo = todo_module.create_todo('テスト', datetime.now() + timedelta(days=1)) edited_todo = todo_module.add_tag(todo, '')
def test_createTodoRaisesNoContentError(self): with self.assertRaises(Exception): todo = todo_module.create_todo('', datetime.now() + timedelta(days=1))
def test_editDeadlineRaisesBeforeDeadlineError(self): with self.assertRaises(Exception): todo = todo_module.create_todo('テスト', datetime.now() + timedelta(days=1)) edited_todo = todo_module.edit_deadline(todo, datetime.now())
def test_createTodoRaisesBeforeDeadlineError(self): with self.assertRaises(Exception): todo = todo_module.create_todo('テスト', datetime.now() - timedelta(days=1))