Beispiel #1
0
    def run_sample():
        output = tasks.format_tasks(tasks.list_tasks(client))

        assert "Test task 1" in output
        assert "Test task 2" in output
        assert "done" in output
        assert "created" in output
    def _():
        output = tasks.format_tasks(tasks.list_tasks(client))

        assert "Test task 1" in output
        assert "Test task 2" in output
        assert "done" in output
        assert "created" in output
    def _():
        output = tasks.format_tasks(tasks.list_tasks(client))

        assert 'Test task 1' in output
        assert 'Test task 2' in output
        assert 'done' in output
        assert 'created' in output
Beispiel #4
0
    def run_sample():
        output = tasks.format_tasks(tasks.list_tasks(client))

        assert 'Test task 1' in output
        assert 'Test task 2' in output
        assert 'done' in output
        assert 'created' in output
def test_delete_task(db_with_4_tasks_id_returned):
    ids = db_with_4_tasks_id_returned.keys()
    first_id, *rest = ids
    tasks.delete(first_id)

    all_ids = [t.id for t in tasks.list_tasks()]
    assert tasks.count() == len(rest)
    assert first_id not in all_ids
Beispiel #6
0
def test_delete_decreases_count(db_with_3_tasks):
    ids = [t.id for t in tasks.list_tasks()]
    # GIVEN 3 items
    assert tasks.count() == 3
    # WHEN we delete one
    tasks.delete(ids[0])
    # THEN counte decreases by 1
    assert tasks.count() == 2
def test_delete_task():
    ids = [tasks.add(t) for t in tasks_to_try]
    first_id, *rest = ids
    tasks.delete(first_id)

    all_ids = [t.id for t in tasks.list_tasks()]
    #assert tasks.get(first_id) == None get не работает на удаленном Task
    assert tasks.count() == len(rest)
    assert first_id not in all_ids
def test_format_tasks(client):
    task1_key = tasks.add_task(client, 'Test task 1')
    tasks.add_task(client, 'Test task 2')
    tasks.mark_done(client, task1_key.id)

    output = tasks.format_tasks(tasks.list_tasks(client))

    assert 'Test task 1' in output
    assert 'Test task 2' in output
    assert 'done' in output
    assert 'created' in output
Beispiel #9
0
def list_tasks(owner):
    """
    List tasks in db.

    If owner given, only list tasks with that owner.

    :param owner:
    :return:
    """
    formatstr = '{: >4} {: >10} {: >5} {}'
    print(formatstr.format('ID', 'owner', 'done', 'summary'))
    print(formatstr.format('--', '-----', '----', '-------'))
    with _tasks_db():
        for t in tasks.list_tasks(owner):
            done = 'True' if t.done else 'False'
            owner = '' if t.owner is None else t.owner
            print(formatstr.format(t.id, owner, done, t.summary))
def test_list_raises():
    """list() should raise an exception with wrong type param."""
    with pytest.raises(TypeError):
        tasks.list_tasks(owner=123)
def test_unique_id(tasks_db, tasks_mult_per_owner):
    """unique_id() should return an unused id."""
    existing_tasks = tasks.list_tasks()
    uid = tasks.unique_id()
    for t in existing_tasks:
        assert uid != t.id
Beispiel #12
0
def test_list():
    con = psycopg2.connect(**DATABASE)
    tasks.add_task(con, datetime.date(2020, 4, 1), "Wake up again")
    tasks.add_task(con, datetime.date(2020, 4, 1), "Make coffee")
    assert tasks.list_tasks(con, datetime.date(
        2020, 4, 1)) == ["Wake up", "Wake up again", "Make coffee"]
def test_list_tasks(db_with_4_tasks_id_returned):
    ids = db_with_4_tasks_id_returned.keys()
    list_of_tasks = [tasks.get(tid) for tid in ids]
    assert tasks.list_tasks() == list_of_tasks
 def _():
     task_list = tasks.list_tasks(client)
     assert [x.key for x in task_list] == [task1_key, task2_key]
Beispiel #15
0
def test_list_raises():
    """list() должно возникнуть исключение с неправильным типом param."""
    with pytest.raises(TypeError):
        tasks.list_tasks(owner=123)
Beispiel #16
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()
def test_list_tasks(client):
    task1_key = tasks.add_task(client, 'Test task 1')
    task2_key = tasks.add_task(client, 'Test task 2')
    task_list = tasks.list_tasks(client)
    assert [x.key for x in task_list] == [task1_key, task2_key]
Beispiel #18
0
 def _():
     task_list = tasks.list_tasks(client)
     assert [x.key for x in task_list] == [task1_key, task2_key]
Beispiel #19
0
def test_list():
    tasks.add_task(datetime.date(2020, 4, 1), "Wake up")
    tasks.add_task(datetime.date(2020, 4, 1), "Make coffee")
    assert tasks.list_tasks(datetime.date(2020, 4,
                                          1)) == ["Wake up", "Make coffee"]
Beispiel #20
0
def test_list_raises():
    """list() should raise an exception with wrong type param."""
    with pytest.raises(TypeError):  # owner must be string or none
        tasks.list_tasks(owner=123)  # here error occurs -> PASSED
def test_delete_all_tasks(db_with_4_tasks):
    tasks.delete_all()
    get_all_tasks = tasks.list_tasks()
    assert len(get_all_tasks) == 0
Beispiel #22
0
def test_list_raises():
    with pytest.raises(TypeError):
        tasks.list_tasks(owner=123)
def test_delete_all_tasks():
    ids = [tasks.add(t) for t in tasks_to_try]
    tasks.delete_all()
    get_all_tasks = tasks.list_tasks()
    assert len(get_all_tasks) == 0
def test_list_tasks_raises():
    # smokeとgetというマーカーは独自に作成したもの
    with pytest.raises(TypeError):
        tasks.list_tasks(owner=123)
def test_list_tasks():
    ids = [tasks.add(t) for t in tasks_to_try]
    list_of_tasks = [tasks.get(tid) for tid in ids]
    assert tasks.list_tasks() == list_of_tasks
def test_unique_id(tasks_db, tasks_mult_per_owner):
    existing_tasks = tasks.list_tasks()
    uid = tasks.unique_id()
    for t in existing_tasks:
        assert uid != t.id