Exemplo n.º 1
0
def delete_task():
    if request.method == 'POST':
        print request.data
        if request.data:
            data = request.data.split()
            return tasks.delete_task(data[0], data[1])
        else:
            return tasks.delete_task(request.form['task_id'], request.form['group_id'])
Exemplo n.º 2
0
def test_delete_task():
    task_id = tasks.save_task({
        "description": "this is a delete task",
        "status": "1"
    })
    task_list = tasks.get_task_list()

    found = False
    for task in task_list:
        if "delete" in task['description']:
            found = True
    assert found
    tasks.delete_task(task_id)

    task_list = tasks.get_task_list()
    found = False
    for task in task_list:
        if "delete" in task['description']:
            found = True

    assert not found
Exemplo n.º 3
0
def test_delete_task(client):
    task_key = tasks.add_task(client, 'Test task 1')
    tasks.delete_task(client, task_key.id)
    assert client.get(task_key) is None
Exemplo n.º 4
0
def test_delete():
    con = psycopg2.connect(**DATABASE)
    tasks.add_task(con, datetime.date(2020, 4, 1), "Wake up")
    tasks.delete_task(con, datetime.date(2020, 4, 1), 1)
    with pytest.raises(TypeError):
        tasks.get_task(con, datetime.date(2020, 4, 1), 1)
Exemplo n.º 5
0
def test_delete_task(client):
    task_key = tasks.add_task(client, 'Test task 1')
    tasks.delete_task(client, task_key.id)
    assert client.get(task_key) is None
Exemplo n.º 6
0
def test_delete():
    tasks.add_task(datetime.date(2020, 4, 1), "Wake up")
    tasks.delete_task(datetime.date(2020, 4, 1), 0)
    with pytest.raises(KeyError):
        tasks.get_task(datetime.date(2020, 4, 1), 0)
Exemplo n.º 7
0
def remove_task(id_task):
    tasks.delete_task(id_task)
    return redirect(url_for('index'))
def edit_mode_handler(update, context):
    # Get user id and user language
    user_id = update.message.from_user.id
    language = get_user_language(user_id=user_id, short=True)

    # Check pushed button of keyboard
    pushed_button = check_button(update, KEYBOARDS["static"]["edit_task_menu"],
                                 language)

    # If pushed button is "back" return user to previous
    # stage of task editing - choice task menu
    if pushed_button == "back":
        if "page" not in context.user_data:
            context.user_data["page"] = 0

        send_choice_tasks_menu(update, context.user_data["page"])

        return "choice_task_handler"

    # If pushed button is "title", proceed to title editing
    elif pushed_button == "title":
        update.message.reply_text(get_message("write_task_title", language),
                                  reply_markup=get_menu_keyboard(
                                      "cancel", language))

        return "new_title_handler"

    # If pushed button is "days_of_the_week",
    # proceed to days of the week editing
    elif pushed_button == "days_of_the_week":
        update.message.reply_text(get_message("write_task_days_of_the_week",
                                              language),
                                  reply_markup=get_menu_keyboard(
                                      "cancel", language))

        return "new_days_of_the_week_handler"

    # If pushed button is "delete", delete task
    elif pushed_button == "delete":
        # Delete task
        delete_task(context.user_data["selected_task_id"])

        # Send message to user about successful deleting
        update.message.reply_text(get_message("task_deleted", language))

        # If user has tasks, send choice task menu
        if get_user_tasks(user_id):
            send_choice_tasks_menu(update)
            context.user_data["page"] = 0

            return "choice_task_handler"

        # Else send editor menu
        else:
            send_editor_menu(update)

            return ConversationHandler.END

    # If more than one condition is incorrect,
    # send message to user push to buttons
    else:
        update.message.reply_text(get_message("click_buttons", language))

        return "edit_mode_handler"
Exemplo n.º 9
0
import psycopg2

from datetime import date
from config import DATABASE
from tasks import add_task, list_tasks, get_task, edit_task, delete_task

if __name__ == "__main__":
    con = psycopg2.connect(**DATABASE)
    with con.cursor() as cursor:
        try:
            add_task(con, date(2020, 4, 1), "Wake up")
            add_task(con, date(2020, 4, 1), "Make coffee")
            add_task(con, date(2020, 4, 1), "Go to the work")
            add_task(con, date(2020, 4, 1), "Save the world")
            add_task(con, date(2020, 4, 1), "Go back home")
            add_task(con, date(2020, 4, 1), "Go to sleep")
            print(list_tasks(con, date(2020, 4, 1)))

            print(get_task(con, date(2020, 4, 1), 1))
            edit_task(con, date(2020, 4, 1), 1, 'Wake up slowly')
            print(get_task(con, date(2020, 4, 1), 1))

            delete_task(con, date(2020, 4, 1), 1)
            print(list_tasks(con, date(2020, 4, 1)))

            con.commit()
        finally:
            if con:
                con.close()
Exemplo n.º 10
0
def test_delete():
    """
    test deleting a record
    """
    tasks.add_task(datetime.date(2020, 4, 1), "Wake up")
    tasks.delete_task(datetime.date(2020, 4, 1), 4)
Exemplo n.º 11
0
def delete_task():
    """Delete a task"""
    print("Deleting...")
    tasks.delete_task(request.form.get('task_id'))
    return 'Success'