Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CI #23

Merged
merged 2 commits into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/panpdf/filters/jupyter.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class Jupyter(Filter):
pandoc_path: Path | None = None
store: Store = field(default_factory=Store)

def set_notebooks_dir(self, notebooks_dir: list[Path]):
self.store.set_notebooks_dir(notebooks_dir)
# def set_notebooks_dir(self, notebooks_dir: list[Path]):
# self.store.set_notebooks_dir(notebooks_dir)

def action(self, image: Image, doc: Doc) -> Image:
url = image.url
Expand Down
27 changes: 26 additions & 1 deletion tests/filters/test_jupyter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest
import yaml
from panflute import Doc, Image
from panflute import Doc, Image, Str

from panpdf.filters.jupyter import Jupyter

Expand Down Expand Up @@ -44,6 +44,12 @@ def test_create_image_file_svg(store: Store):
assert text.startswith("JVBER")


def test_create_image_file_none():
from panpdf.filters.jupyter import create_image_file

assert create_image_file({}) is None


def test_create_defaults_for_standalone(defaults):
from panpdf.filters.jupyter import create_defaults_for_standalone

Expand Down Expand Up @@ -140,3 +146,22 @@ def test_jupyter(store: Store, image_factory, defaults, fmt, standalone):
assert "image/png" in data
assert "text/plain" in data
assert "application/pdf" not in data


def test_jupyter_action():
from panpdf.filters.jupyter import Jupyter

doc = Doc()
jupyter = Jupyter()
image = Image(Str("a"), url="a.png")
assert jupyter.action(image, doc) is image


def test_jupyter_action_error():
from panpdf.filters.jupyter import Jupyter

doc = Doc()
jupyter = Jupyter()
image = Image(Str("a"), url="a.ipynb", identifier="a")
with pytest.raises(ValueError, match=r"\[panpdf\] Unknown"):
jupyter.action(image, doc)
9 changes: 8 additions & 1 deletion tests/filters/test_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import panflute as pf
import pytest
from panflute import Doc, Figure, Para, RawInline, Span, Table
from panflute import Doc, Figure, Image, Para, RawInline, Span, Str, Table

from panpdf.filters.attribute import Attribute
from panpdf.filters.jupyter import Jupyter
Expand Down Expand Up @@ -153,3 +153,10 @@ def test_layout(fig):
assert isinstance(x, pf.MetaList)
f = Path(pf.stringify(x[0]))
assert f.exists()


def test_get_width():
from panpdf.filters.layout import get_width

image = Image(Str("a"), attributes={"width": "50%"})
assert get_width(image, "width") == "0.5\\columnwidth"
2 changes: 1 addition & 1 deletion tests/filters/test_zotero.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,5 @@ def test_zotero_nokey():
from panpdf.filters.zotero import Zotero

doc = Doc()
doc = Zotero().run(doc)
Zotero().finalize(doc)
assert not doc.metadata