def test_del(self): todo.addm_todo("\n".join(self._test_lines_no_pri(self.num))) ran = random.Random() for i in range(self.num, 0, -1): j = ran.randint(1, i) todo.delete_todo(str(j)) self.assertNumLines(0)
def test_delete_todo(): todo.todos = [ { 'title': 'test important todo', 'description': 'This is an important test', 'level': 'IMPORTANT' }, { 'title': 'test medium todo', 'description': 'This is a test', 'level': 'Medium' }, { 'title': 'test unimportant todo', 'description': 'This is an unimportant test', 'level': 'Unimportant' } ] reponse = todo.delete_todo(todo.todos, which = "2") assert reponse == "Deleted todo #2" assert len(todo.todos) == 2 assert todo.todos[0]['level'] == 'IMPORTANT' assert todo.todos[1]['level'] == 'Unimportant' print "OK - test delete todo"
def test_delete_todo(): todo.todos = [ { 'title': 'test important todo', 'description': 'An important test', 'level': 'IMPORTANT' }, { 'title': 'test medium todo', 'description': 'A test', 'level': 'Medium' }, { 'title': 'test unimportant todo', 'description': 'An unimportant test', 'level': 'Unimportant' }, ] response = todo.delete_todo(todo.todos, which='2') assert response == "Deleted todo #2" assert len(todo.todos) == 2 assert todo.todos[0]['level'] == 'IMPORTANT' assert todo.todos[1]['level'] == 'Unimportant' print "ok - test delete todo"
def test_delete_todo_failure(): todo.todos = [ { 'title': 'test important todo', 'description': 'This is an important test', 'level': 'IMPORTANT' } ] for bad_input in ['', 'foo', '0', '43']: response = todo.delete_todo(todo.todos, bad_input) assert response == ("'" + bad_input + "' needs to be the number of a todo!") assert len(todo.todos) == 1 print "OK - test delete todo failures"
def test_delete_todo_failure(): todo.todos = [ { 'title': 'test important todo', 'description': 'An important test', 'level': 'IMPORTANT' }, ] for bad_input in ['', 'foo', '0', '42']: response = todo.delete_todo(todo.todos, which=bad_input) assert response == "'" + bad_input + "' needs to be the number of a todo!" assert len(todo.todos) == 1 print "ok - test delete todo failures"
def test_delete_todo(): todo.todos = [ { "title": "Test unimportant todo", "description": "unimportant todo", "level": "unimportant"}, { "title": "Test medium todo", "description": "medium todo", "level": "medium"}, { "title": "Test important todo", "description": "important todo", "level": "important"}] response = todo.delete_todo(todo.todos, which="2") assert response == "Deleted todo #2" assert len(todo.todos) == 2 assert todo.todos[1]["level"] == "important" assert todo.todos[0]["level"] == "unimportant" print("Ok-delete_todo")
def test_delete_todo(): todo.todos = [{ "title": "Test unimportant todo", "description": "unimportant todo", "level": "unimportant" }, { "title": "Test medium todo", "description": "medium todo", "level": "medium" }, { "title": "Test important todo", "description": "important todo", "level": "important" }] response = todo.delete_todo(todo.todos, which="2") assert response == "Deleted todo #2" assert len(todo.todos) == 2 assert todo.todos[1]["level"] == "important" assert todo.todos[0]["level"] == "unimportant" print("Ok-delete_todo")
def test_delete_todo(): todo.todos = [ { 'title' : 'test important todo', 'description' : 'This is an important test', 'level' : 'IMPORTANT' }, { 'title' : 'test medium todo', 'description' : 'This is a test', 'level' : 'Medium' }, { 'title' : 'test unimportant todo', 'description' : 'This is an unimportant test', 'level' : 'Unimportant' }, ] result = todo.delete_todo(todo.todos, which="2") assert result == "Deleted todo" assert len(todo.todos) == 2 assert todo.todos[0]['level'] == 'IMPORTANT' [==] assert todo.todos[1]['level'] == 'Unimportant' [==]
def process_delete_todo(): time.sleep(3) delete_todo(id)
import todo print("welcom to the cli") print(""" select an option below 1)view all todo 2)search for todo 3)update a todo 4)delete a todo 5)exit """) answer = int(input('choose a number:')) if answer > 5 or answer < 1: print('invalid input') elif answer == 1: todo.view_all_todo() elif answer == 2: the_title = input('enter the title of the todo:') todo.search_todo(the_title) elif answer == 3: new_id = int(input('enter the new title:')) new_title = int('enter the new title') new_desc = int('enter the new description') todo.update_todo(new_id, new_title, new_desc) elif answer == 4: Delete = input('enter the id:') todo.delete_todo(Delete) input('press enter to exit')