Exemple #1
0
def queue_todo(target, type):
    """Check todo list, queue to todo list if not exists"""
    if isinstance(target, str): # one target
        exists = session.query(TodoList).filter(TodoList.name == target).first()
        if not exists:
            session.add(TodoList(name=target, type=type, status=NEW))
    
    elif isinstance(target, list): #multiple targets
        to_add = []
        for each in target:
            exists = session.query(TodoList).filter(TodoList.name == each['name']).first()
            if not exists:
                to_add.append(TodoList(name=each['name'], type=type, status=NEW))
        session.add_all(to_add)

    session.commit()
Exemple #2
0
    def setUp(self):
        self.client = Redis(decode_responses=True)
        self.client.flushdb()

        self.todolist = TodoList(self.client, "peter")

        self.events = [
            "buy some milk", "have lunch", "watch tv", "finish homework",
            "go to sleep"
        ]
    def test_sortTodos(self):
        todo_list = TodoList()
        todo_list.create_todo('Day 2', datetime.now() + timedelta(days=2))
        todo_list.create_todo('Day 1', datetime.now() + timedelta(days=1))
        todo_list.sort_todos()

        self.assertEqual(
            list(map(lambda todo: todo['content'], todo_list.get_todos())),
            ['Day 1', 'Day 2'],
        )
    def test_getTodosWithTag(self):
        todo_list = TodoList()
        todo_list.create_todo('テスト 1', datetime.now() + timedelta(days=1))
        todo_list.create_todo('テスト 2', datetime.now() + timedelta(days=2))

        def editor(todo):
            return {
                **todo,
                'tags': set(['プライベート']),
            }

        todo_list.edit_todo(0, editor)

        self.assertEqual(len(todo_list.get_todos('プライベート')), 1)
    def test_editTodo(self):
        todo_list = TodoList()
        todo_list.create_todo('テスト', datetime.now() + timedelta(days=1))

        def editor(todo):
            return {
                **todo,
                'content': 'テスト (編集済み)',
            }

        todo_list.edit_todo(0, editor)

        self.assertEqual(
            todo_list.get_todos()[0]['content'],  # *1
            'テスト (編集済み)',
        )
Exemple #6
0
 def setUp(self):
     self.todo_list = TodoList()
Exemple #7
0
from todo import Todo
from todo_list import TodoList

print('''
1. Wyswietl liste.
2. Dodaj zadanie.
3. Usun zadanie.
4. Wyjdz.
''')

todo_list = TodoList()

while True:
    option = input('Wybierz czynnosc: (1|2|3|4): ')

    if option == '1':
        todo_list.show()

    if option == '2':
        content = input('Podaj tresc zadania: ')
        new_todo = Todo(content)
        todo_list.add(todo=new_todo)

    if option == '3':
        idx = int(input('Podaj indeks zadania do usuniecia: '))
        todo_list.remove(idx)

    if option == '4':
        break

print('Koniec dzialania progrmu.')
from os import environ
from datetime import datetime, timedelta
from flask import Flask, request, render_template
from flask.json import jsonify
from todo import Todo, edit_deadline, finish_todo, add_tag, remove_tag, to_json
from todo_list import TodoList

app = Flask(__name__)
app.config['TEMPLATES_AUTO_RELOAD'] = True

todolist = TodoList()


@app.after_request
def after_request(response):
    response.headers.add('Access-Control-Allow-Origin', '*')
    response.headers.add('Access-Control-Allow-Headers',
                         'Content-Type,Authorization')
    response.headers.add('Access-Control-Allow-Methods',
                         'GET,PUT,POST,DELETE,OPTIONS')

    return response


@app.route('/', methods=['GET'])
def get_index():
    return render_template('index.html')


@app.route('/assets/<path:file_path>')
def assets(file_path):
    def test_getTodos(self):
        todo_list = TodoList()
        todo_list.create_todo('テスト 1', datetime.now() + timedelta(days=1))
        todo_list.create_todo('テスト 2', datetime.now() + timedelta(days=2))

        self.assertEqual(len(todo_list.get_todos()), 2)
 def test_getTodoRaisesInvalidIdError(self):
     with self.assertRaises(Exception):
         todo_list = TodoList()
         todo_list.get_todo(0)
    def test_getTodo(self):
        todo_list = TodoList()
        todo_list.create_todo('テスト 1', datetime.now() + timedelta(days=1))
        todo_list.create_todo('テスト 2', datetime.now() + timedelta(days=2))

        self.assertEqual(todo_list.get_todo(0)['content'], 'テスト 1')
 def test_editTodoRaisesInvalidIdError(self):
     with self.assertRaises(Exception):
         todo_list = TodoList()
         todo_list.edit_todo(0, lambda todo: todo)
    def test_deleteTodo(self):
        todo_list = TodoList()
        todo_list.create_todo('テスト', datetime.now() + timedelta(days=1))
        todo_list.delete_todo(0)

        self.assertEqual(len(todo_list.get_todos()), 0)