Esempio n. 1
0
async def test_get_all_collections(database):
    collections = await get_collections(
        database,
        test_user,
        user_id = test_user.id,
        only_owned = False,
    )

    expected = [
        Collection(
            **admin_shared_col.dict(),
            user_id = test_user.id,
            can_edit = False,
        ),
        Collection(
            **admin_shared_edit_col.dict(),
            user_id = test_user.id,
            can_edit = True,
        ),
        Collection(
            **test_public_col.dict(),
            user_id = test_user.id,
            can_edit = True,
        ),
        Collection(
            **test_test_col.dict(),
            user_id = test_user.id,
            can_edit = True,
        ),
    ]

    assert collections == expected
Esempio n. 2
0
def test_get_owned_public_collection(client, user_headers):
    response = client.get(
        "/users/test/collections/public",
        headers = user_headers,
    )

    expected = dict(
        **test_public_col.dict(include={
            "id", "owner", "name", "title", "public", "deleted",
        }),
        can_edit = True,
    )

    assert response.status_code == 200
    assert response.json() == expected
Esempio n. 3
0
def test_get_owned_collections(client, user_headers):
    response = client.get(
        "/users/test/collections",
        headers = user_headers,
    )

    expected = [
        dict(
            **test_public_col.dict(),
            can_edit = True,
        ),
        dict(
            **test_test_col.dict(),
            can_edit = True,
        ),
    ]

    assert response.status_code == 200
    assert response.json() == expected