async def test_del_release_from_collection_doesnt_exist( db: Connection, graphql_query, snapshot, ): query = """ mutation { delReleaseFromCollection(collectionId: 1, releaseId: 1) { collection { ...CollectionFields } release { ...ReleaseFields } } } """ col = collection.from_id(1, db) assert col is not None releases_before = collection.releases(col, db) success, data = await graphql_query(query) assert success is True snapshot.assert_match(data) releases_after = collection.releases(col, db) assert releases_before == releases_after
async def test_add_release_to_collection_already_exists( db: Connection, graphql_query, snapshot, ): query = """ mutation { addReleaseToCollection(collectionId: 5, releaseId: 2) { collection { ...CollectionFields } release { ...ReleaseFields } } } """ col = collection.from_id(5, db) assert col is not None releases_before = collection.releases(col, db) success, data = await graphql_query(query) assert success is True snapshot.assert_match(data) releases_after = collection.releases(col, db) assert releases_before == releases_after
def test_insert_into_inbox_collection(factory: Factory, db: Connection): # Create two new inboxes. usr1, _ = factory.user(conn=db) usr2, _ = factory.user(conn=db) rls = factory.release(conn=db) _insert_into_inbox_collections(rls, db) inbox1 = collection.inbox_of(usr1.id, db) inbox2 = collection.inbox_of(usr2.id, db) assert rls in collection.releases(inbox1, db) assert rls in collection.releases(inbox2, db)
async def test_del_release_from_collection(db: Connection, graphql_query, snapshot): query = """ mutation { delReleaseFromCollection(collectionId: 5, releaseId: 2) { collection { ...CollectionFields } release { ...ReleaseFields } } } """ success, data = await graphql_query(query) assert success is True snapshot.assert_match(data) col = collection.from_id(5, db) assert col is not None assert 2 not in [r.id for r in collection.releases(col, db)]
def resolve_releases(obj: collection.T, info: GraphQLResolveInfo) -> list[release.T]: return collection.releases(obj, info.context.db)