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
async def test_update_collection(database): async with database.transaction(force_rollback=True): update = CollectionIn( name = "updated", title = "Another title", public = True, ) await update_collection( database, test_test_col.id, value = update, ) collection = await get_collection( database, test_user, user_id = test_user.id, collection_name = update.name, ) expected = Collection( **test_test_col.dict(exclude={"name", "title", "public"}), **update.dict(), user_id = test_user.id, can_edit = True, ) assert collection == expected
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
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
async def test_get_owned_private_collection(database): collection = await get_collection( database, test_user, user_id = test_user.id, collection_name = test_test_col.name, ) expected = Collection( **test_test_col.dict(), user_id = test_user.id, can_edit = True, ) assert collection == expected
async def test_get_other_private_collection_include_private(database): collection = await get_collection( database, admin_user, user_id = test_user.id, collection_name = test_test_col.name, include_private = True, ) expected = Collection( **test_test_col.dict(), user_id = admin_user.id, can_edit = True, ) assert collection == expected