Esempio n. 1
0
async def test_get_other_owned_collections(database):
    collections = await get_collections(
        database,
        test_user,
        user_id = admin_user.id,
    )

    expected = [
        Collection(
            **admin_public_col.dict(),
            user_id = test_user.id,
            can_edit = False,
        ),
        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,
        ),
    ]

    assert collections == expected
Esempio n. 2
0
def test_get_owned_collections_as_admin(client, admin_headers):
    response = client.get(
        "/users/admin/collections",
        headers = admin_headers,
    )

    expected = [
        dict(
            **admin_public_col.dict(),
            can_edit = True,
        ),
        dict(
            **admin_private_col.dict(),
            can_edit = True,
        ),
        dict(
            **admin_shared_col.dict(),
            can_edit = True,
        ),
        dict(
            **admin_shared_edit_col.dict(),
            can_edit = True,
        ),
    ]

    assert response.status_code == 200
    assert response.json() == expected
Esempio n. 3
0
async def test_get_other_public_collection(database):
    collection = await get_collection(
        database,
        test_user,
        user_id = admin_user.id,
        collection_name = admin_public_col.name,
    )

    expected = Collection(
        **admin_public_col.dict(),
        user_id = test_user.id,
        can_edit = False,
    )

    assert collection == expected
Esempio n. 4
0
def test_get_owned_public_collection_as_admin(client, admin_headers):
    response = client.get(
        "/users/admin/collections/public",
        headers = admin_headers,
    )

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

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

    expected = [
        dict(
            **admin_public_col.dict(),
            can_edit = False,
        ),
        dict(
            **admin_shared_col.dict(),
            can_edit = False,
        ),
        dict(
            **admin_shared_edit_col.dict(),
            can_edit = True,
        ),
    ]

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