Skip to content

Conversation

@Divyansh8843
Copy link
Contributor

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.py

  • Created 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.blog

Result: ✅ All tests passed (3/3)

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.

1 participant