def test_duplicate_genre(factory: Factory, db: Connection): rls = factory.release(conn=db) _insert_into_genre_collections(rls, ["1, 2, 3", "2/3"], db) collections = release.collections(rls, db) for genre in ["1", "2", "3"]: col = collection.from_name_type_user(genre, CollectionType.GENRE, db) assert col in collections
def resolve_collages(obj: release.T, info: GraphQLResolveInfo) -> list[collection.T]: return release.collections(obj, info.context.db, type=CollectionType.COLLAGE)
def resolve_labels(obj: release.T, info: GraphQLResolveInfo) -> list[collection.T]: return release.collections(obj, info.context.db, type=CollectionType.LABEL)
def test_insert_into_genre_collections_nothing(factory: Factory, db: Connection): rls = factory.release(conn=db) _insert_into_genre_collections(rls, [" "], db) assert not release.collections(rls, db)
def test_insert_into_genre_preexisting(factory: Factory, db: Connection): rls = factory.release(conn=db) col = factory.collection(type=CollectionType.GENRE, conn=db) _insert_into_genre_collections(rls, [col.name], db) assert collection.from_id(col.id, db) in release.collections(rls, db)
def test_insert_into_label_collection_new(factory: Factory, db: Connection): rls = factory.release(conn=db) _insert_into_label_collection(rls, "asdf", db) col = collection.from_name_type_user("asdf", CollectionType.LABEL, db) assert col in release.collections(rls, db)
def test_insert_into_label_collection_existing(factory: Factory, db: Connection): rls = factory.release(conn=db) col = factory.collection(type=CollectionType.LABEL, conn=db) _insert_into_label_collection(rls, col.name, db) assert collection.from_id(col.id, db) in release.collections(rls, db)
def test_insert_into_label_collection_nonexistent(factory: Factory, db: Connection): rls = factory.release(conn=db) _insert_into_label_collection(rls, "", db) assert not release.collections(rls, db)