Skip to content

feat: add basic test suite#80

Merged
PascalRepond merged 1 commit intorero:stagingfrom
PascalRepond:rep-tests
Mar 26, 2026
Merged

feat: add basic test suite#80
PascalRepond merged 1 commit intorero:stagingfrom
PascalRepond:rep-tests

Conversation

@PascalRepond
Copy link
Copy Markdown
Contributor

  • Add pytest tests for API, views, utils (conftest, test data fixtures)
  • Rewrite README with usage guide, permissions docs, and full config reference
  • Fix wikilink url_formatter to use 'wiki.page' instead of 'display'
  • Enable pytest in test script and ignore tests/data in doctest collection

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9c22dbc1-440e-4b1f-876e-47576f232c8d

📥 Commits

Reviewing files that changed from the base of the PR and between 2894ce9 and 051d93e.

📒 Files selected for processing (11)
  • README.md
  • flask_wiki/utils.py
  • pyproject.toml
  • scripts/test
  • tests/conftest.py
  • tests/data/home.md
  • tests/data/sample.md
  • tests/data/sample_fr.md
  • tests/test_api.py
  • tests/test_utils.py
  • tests/test_views.py
✅ Files skipped from review due to trivial changes (5)
  • pyproject.toml
  • tests/data/home.md
  • tests/data/sample.md
  • README.md
  • tests/test_utils.py
🚧 Files skipped from review as they are similar to previous changes (4)
  • scripts/test
  • flask_wiki/utils.py
  • tests/test_api.py
  • tests/test_views.py

Walkthrough

Rewrites README into a comprehensive user and developer guide; tweaks wikilink() to use the "wiki.page" endpoint; adjusts pytest ignore options; enables tests in scripts/test; and adds extensive pytest fixtures, test data, and new test suites for API, utils, and views (including file uploads, i18n, permissions, and search).

Changes

Cohort / File(s) Summary
Documentation
README.md
Complete rewrite: installation, quick-start (app & factory), routing (WIKI_URL_PREFIX), CLI/build steps for Whoosh index, storage/metadata format, permissions model with Flask-Login example, config keys (content/storage/templates/i18n), Markdown extension notes, development setup, and BSD-3 license.
Utilities
flask_wiki/utils.py
wikilink() now calls url_formatter with endpoint key "wiki.page" (was "display"); link generation otherwise unchanged.
Project config & scripts
pyproject.toml, scripts/test
pyproject.toml: pytest addopts updated to ignore tests/data; scripts/test: when no args, now runs tests after pretests (previously commented out).
Test fixtures & setup
tests/conftest.py
New pytest fixtures: module-scoped app creates isolated temp wiki tree, copies tests/data, configures app (upload/content/index dirs, languages), registers /language/<ln>, initializes extensions (Bootstrap4, Babel) and Wiki/search index; client, per-test wiki, and png_file fixtures added.
Test data (Markdown fixtures)
tests/data/home.md, tests/data/sample.md, tests/data/sample_fr.md
Added Markdown fixture pages with YAML front-matter and content: English home/sample pages and a French variant (sample_fr.md) for i18n tests.
API tests
tests/test_api.py
New tests for Processor, Page, and WikiBase: markdown→HTML rendering (headings, bold, code, tables), front-matter metadata, TOC generation, page lifecycle (load/save/delete/move), path-traversal protection, language variants, tag aggregation/filtering, and Whoosh search integration.
Utility tests
tests/test_utils.py
Unit tests for clean_url normalization and wikilink conversion (including no-conversion inside <code> and absence-of-links behavior).
View/integration tests
tests/test_views.py
13 integration tests covering index redirects, page display/404, edit/create/delete flows (including form POST/redirect), preview rendering, search route, files listing, file upload/delete (valid .png persisted; invalid .exe not saved), and permission-denial (403) scenarios by overriding permission callables.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: add basic test suite' clearly and directly summarizes the main change - the addition of a comprehensive test suite with pytest tests for API, views, and utils, plus supporting fixtures.
Description check ✅ Passed The description is directly related to the changeset, outlining the four main components: pytest test coverage, README documentation improvements, wikilink fix, and test script updates.
Docstring Coverage ✅ Passed Docstring coverage is 89.13% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]

This comment was marked as resolved.

- Add pytest tests for API, views, utils (conftest, test data fixtures)
- Rewrite README with usage guide, permissions docs, and full config reference
- Fix wikilink url_formatter to use 'wiki.page' instead of 'display'
- Enable pytest in test script and ignore tests/data in doctest collection

Co-Authored-by: Pascal Repond <pascal.repond@rero.ch>
@PascalRepond PascalRepond merged commit 91b3900 into rero:staging Mar 26, 2026
11 checks passed
@PascalRepond PascalRepond deleted the rep-tests branch March 26, 2026 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants