Add unit tests for Blog app and tag filtering #593
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a dedicated unit test suite for the blog app (
bakerydemo/blog/tests.py). Previously, the blog app lacked automated tests, making it difficult to confidently validate changes and prevent regressions—particularly around tag filtering and caching behavior.Changes
Added
bakerydemo/blog/tests.pyCreated BlogPageTests extending WagtailPageTests
Implemented the following tests:
test_blog_index_page_renders – Confirms the blog index page returns 200 OK and uses the correct template
test_tag_filtering – Ensures tag-based URLs (e.g., /blog/tags/bread/) correctly filter blog posts
test_get_posts_method – Validates the get_posts(tag=...) model method logic
Why This Matters
These tests establish baseline coverage for core blog functionality, improve confidence when refactoring, and help prevent regressions—especially for tag filtering and related fixes.
Testing
Tests were run locally using:
python manage.py test bakerydemo.blogResult: ✅ All tests passed (3/3)