def test_process_tarball_with_wrong_utf_path_inside(tarball_with_wrong_utf): """Test simple API for extracting and linking files to TeX context.""" plots = plotextractor.process_tarball(tarball_with_wrong_utf, context=True) assert len(plots) == 1 assert "unicode_path.tar.gz_files/cute_cat.png" in plots[0]['url'] assert plots[0]['captions'] == ['słodki kociak!'] assert plots[0]['name'] == 'cute_cat'
def test_process_api_with_image_rotation(tarball_rotation): """Test simple API for extracting and linking files to TeX context.""" plots = plotextractor.process_tarball(tarball_rotation) assert len(plots) == 22 assert "label" in plots[0] assert "original_url" in plots[0] assert "captions" in plots[0] assert "name" in plots[0]
def test_process_api_with_subfloats(tarball_subfloat): """Test simple API for extracting and linking files to TeX context.""" plots = plotextractor.process_tarball(tarball_subfloat) assert len(plots) == 24 assert "label" in plots[0] assert "original_url" in plots[0] assert "captions" in plots[0] assert "name" in plots[0]
def test_process_api_with_nested(tarball_nested_folder): """Test simple API for extracting and linking files to TeX context.""" plots = plotextractor.process_tarball(tarball_nested_folder, context=True) assert len(plots) == 9 assert "contexts" in plots[0] assert "label" in plots[0] assert "original_url" in plots[0] assert "captions" in plots[0] assert "name" in plots[0]
def test_process_api_with_nested(tarball_nested_folder): """Test simple API for extracting and linking files to TeX context.""" plots = plotextractor.process_tarball(tarball_nested_folder, context=True) assert len(plots) == 9 assert "contexts" in plots[0] assert "label" in plots[0] assert "original_url" in plots[0] assert "captions" in plots[0] assert "name" in plots[0]
def test_process_api(tarball_flat): """Test simple API for extracting and linking files to TeX.""" plots = plotextractor.process_tarball(tarball_flat) assert len(plots) == 22 assert "label" in plots[0] assert plots[0]["label"] assert "url" in plots[0] assert "original_url" in plots[0] assert "captions" in plots[0] assert plots[0]["captions"] assert "name" in plots[0] assert plots[0]["name"]
def test_process_api(tarball_flat): """Test simple API for extracting and linking files to TeX.""" plots = plotextractor.process_tarball(tarball_flat) assert len(plots) == 22 assert "label" in plots[0] assert plots[0]["label"] assert "url" in plots[0] assert "original_url" in plots[0] assert "captions" in plots[0] assert plots[0]["captions"] assert "name" in plots[0] assert plots[0]["name"]
def test_process_api_preserves_ordering_of_figures_with_one_source_file( tarball_flat): plots = plotextractor.process_tarball(tarball_flat) expected = [ 'd15-120f1', 'd15-120f2', 'd15-120f3a', 'd15-120f3b', 'd15-120f3c', 'd15-120f3d', 'd15-120f4', 'd15-120f5', 'd15-120f6a', 'd15-120f6b', 'd15-120f6c', 'd15-120f6d', 'd15-120f6e', 'd15-120f7', 'd15-120f8', 'd15-120f9', 'd15-120f10', 'd15-120f11', 'd15-120f12a', 'd15-120f12b', 'd15-120f12c', 'd15-120f13' ] labels = [plot['name'] for plot in plots] assert len(plots) == 22 assert expected == labels
def test_process_api_no_tex(tarball_no_tex): """Test simple API for extracting and linking files to TeX.""" with pytest.raises(plotextractor.errors.NoTexFilesFound): plotextractor.process_tarball(tarball_no_tex)
def test_process_api_invalid_text(): """Test simple API for extracting and linking files to TeX.""" with tempfile.NamedTemporaryFile() as f: with pytest.raises(plotextractor.errors.InvalidTarball): plotextractor.process_tarball(f.name)
def test_process_api_no_tex(tarball_no_tex): """Test simple API for extracting and linking files to TeX.""" with pytest.raises(plotextractor.errors.NoTexFilesFound): plotextractor.process_tarball(tarball_no_tex)
def test_process_api_invalid_text(): """Test simple API for extracting and linking files to TeX.""" with tempfile.NamedTemporaryFile() as f: with pytest.raises(plotextractor.errors.InvalidTarball): plotextractor.process_tarball(f.name)