Skip to content
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
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
version: 2
updates:
# Each group puts all of a month's updates into one PR.
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
groups:
actions:
patterns: ["*"]
- package-ecosystem: uv
directory: /
schedule:
interval: monthly
groups:
python-packages:
patterns: ["*"]
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
- uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
- run: uv sync --locked
- run: uv run ruff check .
- run: uv run ruff format --check .
Expand All @@ -38,14 +38,14 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
- uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
- run: uv sync --locked
- name: Run tests
run: uv run pytest --html=reports/test-report.html --self-contained-html
- name: Upload test report
if: always()
id: upload
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: test-report
path: reports/test-report.html
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
- uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
- run: uv sync --locked --group docs
# --strict: a broken link or a page missing from the menu stops the build.
- run: uv run --group docs mkdocs build --strict --site-dir site
Expand Down
6 changes: 3 additions & 3 deletions src/paperpi/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ def _comment(text: str) -> list[str]:
def _check_reads_back(text: str, values: Mapping[str, Any]) -> None:
"""Raise ``ValueError`` unless PaperPi reads ``text`` back as exactly ``values``.

tomlkit writes a few things (such as the control character ESC) in a newer form of
TOML than Python's reader understands; such a block would make the whole file
unreadable.
Some tomlkit versions write a few things in a newer form of TOML than Python's
reader understands (before 0.15.2, the control character ESC); such a block would
make the whole file unreadable.
"""
expected = {"plugin": [{k: plain(v) for k, v in values.items()}]}
try:
Expand Down
18 changes: 14 additions & 4 deletions tests/test_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pydantic import BaseModel, Field, SecretStr

from paperpi import config, plugins
from paperpi.example import example_config, plugin_block, setup_config
from paperpi.example import _check_reads_back, example_config, plugin_block, setup_config
from paperpi.plugin import PluginEntry, PluginSettings

EXAMPLE_FILE = Path(__file__).parent.parent / "paperpi.example.toml"
Expand Down Expand Up @@ -143,7 +143,7 @@ def test_block_refuses_values_the_plugin_would_not_accept(values, message):


def test_block_refuses_what_paperpi_could_not_read_back():
# tomlkit writes the control character ESC in a form Python's TOML reader doesn't know.
# Control characters such as ESC are refused.
with pytest.raises(ValueError, match="control characters"):
plugin_block(plugins.load("basic_clock"), "b", {"name": "B\x1bad"})
# Characters Python counts as line breaks, which the web interface's line counting skips.
Expand All @@ -152,8 +152,18 @@ def test_block_refuses_what_paperpi_could_not_read_back():
plugin_block(plugins.load("basic_clock"), "b", {"name": name})
with pytest.raises(ValueError, match="only letters, digits"):
plugin_block(plugins.load("basic_clock"), "B\x1bad")
with pytest.raises(ValueError, match="reads it back"):
plugin_block(plugins.load("met_no"), "Weather", {"place": "B\x1bad"})


def test_check_reads_back_refuses_text_python_cannot_read():
# tomlkit before 0.15.2 wrote ESC as \e, which Python's TOML reader refuses.
values = {"id": "b", "type": "met_no", "place": "B\x1bad"}
text = '[[plugin]]\nid = "b"\ntype = "met_no"\nplace = "B\\ead"\n'
with pytest.raises(ValueError, match="reads it back:"):
_check_reads_back(text, values)
# Text Python reads, but as different values.
with pytest.raises(ValueError, match="reads it back the same"):
_check_reads_back(text.replace("B\\ead", "Bad"), values)
_check_reads_back(text.replace("\\e", "\\u001b"), values)


def test_config_file_refuses_control_characters_in_names():
Expand Down
10 changes: 8 additions & 2 deletions tests/test_web_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,15 @@ def test_the_library_page_shows_titles_labels_and_names_added(client):
assert page.count("Added: ") == 2
# Every word of the search is looked for in the title, type, description and labels.
assert 'data-search="weather met_no the weather for the next 12 hours' in page
assert "wind. requires setup requires internet next 12 hours three rows: now, +3 and +6 hours" in page
assert (
"wind. requires setup requires internet next 12 hours three rows: now, +3 and +6 hours"
in page
)
# A plugin with more than one layout lists their titles, the default first.
assert "Layouts: Next 12 hours, Three rows: now, +3 and +6 hours, Three columns: now, +3 and +6 hours," in page
assert (
"Layouts: Next 12 hours, Three rows: now, +3 and +6 hours,"
" Three columns: now, +3 and +6 hours," in page
)
assert page.count('class="hint layouts"') == sum(
len(item.plugin.layouts) > 1 for item in web_plugins.library()
)
Expand Down
Loading
Loading