예제 #1
0
    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)
예제 #2
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"
예제 #3
0
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"
예제 #4
0
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"
예제 #5
0
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"
예제 #6
0
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")
예제 #7
0
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")
예제 #8
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'
        },
    ]
    
    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' [==]
예제 #9
0
 def process_delete_todo():
     time.sleep(3)
     delete_todo(id)
예제 #10
0
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')