def test_from_chunks_fail_length_mismatch(chunk_1, chunk_2, chunk_3): """Initialize a :class:`MultimodalDocument` expect to fail which has 3 chunks with 2 modalities. """ with pytest.raises(LengthMismatchException): MultimodalDocument.from_chunks(chunks=[chunk_1, chunk_2, chunk_3])
def test_from_chunks_fail_multiple_granularity(chunk_1, chunk_2, chunk_4): """Initialize a :class:`MultimodalDocument` expect to fail which has 3 chunks with different granularity value, expect all chunks has the same granularity value. """ with pytest.raises(BadDocType): MultimodalDocument.from_chunks(chunks=[chunk_1, chunk_2, chunk_4])
def test_from_chunks_success(chunk_1, chunk_2): md = MultimodalDocument.from_chunks(chunks=[chunk_1, chunk_2]) assert len(md.modalities) == 2 assert 'visual' and 'textual' in md.modalities assert len(md.chunks) == 2 assert md.granularity == md.chunks[0].granularity - 1