Exemple #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
Exemple #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
Exemple #3
0
async def test_get_other_shared_collection(database):
    collection = await get_collection(
        database,
        test_user,
        user_id = admin_user.id,
        collection_name = admin_shared_col.name,
    )

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

    assert collection == expected
Exemple #4
0
def test_get_other_shared_collection(client, user_headers):
    response = client.get(
        "/users/admin/collections/shared",
        headers = user_headers,
    )

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

    assert response.status_code == 200
    assert response.json() == expected
Exemple #5
0
async def test_get_all_collections_including_deleted(database):
    collections = await get_collections(
        database,
        test_user,
        user_id = test_user.id,
        include_deleted = True,
        only_owned = False,
    )

    expected = [
        Collection(
            **test_deleted_col.dict(),
            user_id = test_user.id,
            can_edit = True,
        ),
        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
Exemple #6
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