Ejemplo n.º 1
0
class TodoTestCase(object):
    def __init__(self):
        self._todo = Todo()

    def set_up(self):
        self._todo.clear()

    def test_add_todo_adds_pending_item(self):
        self._todo.add("Sandwich")

        items = self._todo.items()
        assert_equal(("Sandwich", Todo.PENDING), items)

    def test_add_return_value(self):
        add_return_index = self._todo.add("Sandwich")
        assert_equal(0, add_return_index)
Ejemplo n.º 2
0
class TodoTestCase(object):

    def __init__(self):
        self._todo = Todo()

    def set_up(self):
        self._todo.clear()

    def test_add_todo_adds_pending_item(self):
        self._todo.add("Sandwich")

        items = self._todo.items()
        assert_equal(("Sandwich", Todo.PENDING), items)

    def test_add_return_value(self):
        add_return_index = self._todo.add("Sandwich")
        assert_equal(0, add_return_index)
Ejemplo n.º 3
0
def main():
    """ main UI function """

    todo_list = Todo()

    while True:
        cmd, args = ask_option()
        cmd = cmd.lower()

        try:
            if cmd == "add":
                todo_list.add(args)

            elif cmd == "del":
                todo_list.remove(args)

            elif cmd == "ls" and args:
                print(todo_list.show(args))

            elif cmd == "ls":
                for todo in todo_list.show_all():
                    print(todo)

            elif cmd == "save":
                todo_list.save(args)

            elif cmd == "load":
                todo_list.load(args)

            elif cmd == "help":
                print(HELPER)

            elif cmd == "q":
                break

            else:
                print("Invalid option")

        except Exception as err:
            print("ERROR: " + str(type(err)) + " - " + str(err))
Ejemplo n.º 4
0
def todo():
    todos = Todo()
    if len(sys.argv) == 1:
        print('Incorrect usage!')
    else:
        cmd = sys.argv[1]
        if cmd == 'add':
            name = sys.argv[2]
            todos.add(name)
        elif cmd == 'remove':
            id = sys.argv[2]
            todos.remove(id)
        elif cmd == 'show':
            todos.show()
        elif cmd == 'done':
            id = sys.argv[2]
            todos.done(id)
        elif cmd == 'undone':
            id = sys.argv[2]
            todos.undone(id)
        elif cmd == 'clear':
            todos.clear()
    todos.save()
Ejemplo n.º 5
0
# # dunder or magic method


from todo import Todo

# x= [1,2,3,4]

# print (len(x))

# # the above code can be written in dunder method below and achieve the same result Thus:

# print(x.__len__())

#=========================


k_todo = Todo(name='Kingsley')

e_todo= Todo(name= 'Emmanuel')

k_todo.add('buy milk')
k_todo.add('code python')
k_todo.add('cook dinner')

print(k_todo > e_todo)
Ejemplo n.º 6
0
# dunder or magic method

# x = [1,2,3,4]

# # it does same thing in the back
# print(dir(x))
# print(x.__dir__())
# print(2+2)
# print(int.__add__(2,2))

from todo import Todo

s_todo = Todo(name='Sarkash')
t_todo = Todo(name='Tina')

s_todo.add('take the dogs out')
s_todo.add('have breakfast')
s_todo.add('do nothing then')

t_todo.add('company with Sarkash')

print(s_todo > t_todo)
print(s_todo < t_todo)
Ejemplo n.º 7
0
from todo import Todo
import sys
app = Todo()
params = sys.argv

if len(params) <= 1:
    app.help()
    sys.exit()

command = params[1]

if command == 'add':
    app.add(params)
elif command in ('today', 'day', 'to'):
    app.today(params)
elif command in ('show', 'list'):
    app.show(params)
elif command in ('delete', 'remove'):
    app.delete(params)
elif command in ('mark', 'done'):
    app.mark_done(params)
elif command == 'help':
    app.help()
else:
    app.help()