Ejemplo n.º 1
0
    async def add():
        result = await db_connection.execute_fetchone(
            sticker.insert().values(**fixt_wall_item))
        await db_connection.commit()

        fnd_wall_item = await db_connection.execute_fetchone(
            sticker.select().where(sticker.c.id == result.id))
        return fnd_wall_item
Ejemplo n.º 2
0
async def test_create_sticker(db_connection):
    await db_connection.execute(
        sticker.insert().values(title='abc', description='def')
    )
    result = list(await db_connection.execute(sticker.select()))

    assert len(result) == 1
    assert result[0].title == 'abc'
    assert result[0].description == 'def'
Ejemplo n.º 3
0
async def test_list_wall(test_client_auth, db_connection, fixt_wall_item):
    await db_connection.execute(
        sticker.insert().values(**fixt_wall_item)
    )
    await db_connection.execute(
        sticker.insert().values(**fixt_wall_item)
    )
    await db_connection.commit()

    resp = await test_client_auth.get('/wall')

    assert resp.status == 200

    data = await resp.json()
    assert data == [
        {'id': Any(), **fixt_wall_item},
        {'id': Any(), **fixt_wall_item},
    ]
Ejemplo n.º 4
0
async def test_delete_wall(test_client_auth, db_connection, fixt_wall_item):
    new_sticker = await db_connection.execute_fetchone(
        sticker.insert().values(**fixt_wall_item)
    )
    await db_connection.commit()

    resp = await test_client_auth.delete('/wall/{}'.format(new_sticker.id))

    assert resp.status == 204

    result = list(await db_connection.execute(sticker.select()))
    assert len(result) == 0
Ejemplo n.º 5
0
async def test_single_wall(test_client_auth, db_connection, fixt_wall_item):
    new_sticker = await db_connection.execute_fetchone(
        sticker.insert().values(**fixt_wall_item)
    )
    await db_connection.commit()

    resp = await test_client_auth.get('/wall/{}'.format(new_sticker.id))

    assert resp.status == 200

    data = await resp.json()
    assert data == {'id': new_sticker.id, **fixt_wall_item}
Ejemplo n.º 6
0
async def test_update_wall(
        test_client_auth, db_connection, fixt_wall_item, fixt_db_user
):
    new_sticker = await db_connection.execute_fetchone(
        sticker.insert().values(**fixt_wall_item)
    )
    await db_connection.commit()

    resp = await test_client_auth.put(
        '/wall/{}'.format(new_sticker.id), data=json.dumps(fixt_wall_item))

    assert resp.status == 201

    data = await resp.json()
    assert data == {'id': Any(), **fixt_wall_item}

    result = list(await db_connection.execute(sticker.select()))
    assert len(result) == 1
    assert result[0].title == 'Hi'
    assert result[0].description == 'Desc'