Skip to content

Conversation

@fsbraun
Copy link
Member

@fsbraun fsbraun commented Nov 3, 2025

Summary by Sourcery

Add comprehensive test coverage for djangocms_stories admin, managers, and template tags, and for djangocms_blog managers; clean up manager methods and test factories

Enhancements:

  • Remove deprecated published methods from GenericDateTaggedManager and add docstrings to convenience methods

Tests:

  • Add extensive djangocms_stories admin tests covering PostAdmin, ConfigAdmin, CategoryAdmin, SiteListFilter, and extension registration
  • Add comprehensive tests for djangocms_blog managers covering tag filtering, site filtering, date aggregation, and version-aware querysets
  • Add tests for djangocms_stories template tags including namespace_url, media_plugins, media_images, and absolute_url

Chores:

  • Remove default_site fixture from test factories to eliminate hardcoded Site dependency

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 3, 2025

Reviewer's Guide

This PR significantly expands test coverage across the admin interface, model managers, and template tags, and cleans up the GenericDateTaggedManager by removing redundant methods and adding docstrings, as well as tidying up test factories.

Class diagram for updated GenericDateTaggedManager

classDiagram
class GenericDateTaggedManager {
    +get_queryset(*args, **kwargs)
    +filter_by_language(language, current_site=True)
    +on_site(site=None)
    +get_months(queryset=None, current_site=True)
}
GenericDateTaggedManager --|> TaggedFilterItem
GenericDateTaggedManager --|> WithUserMixin
GenericDateTaggedManager --|> models.Manager
Loading

Class diagram for removed methods in GenericDateTaggedManager

classDiagram
class GenericDateTaggedManager {
    -published(current_site=True)
    -published_on_rss(current_site=True)
    -available(current_site=True)
    -archived(current_site=True)
    -published_future(current_site=True)
}
Loading

File-Level Changes

Change Details Files
Add comprehensive admin interface tests
  • Implement tests for PostAdmin list filters, lookups and queryset behaviors
  • Verify fieldsets under various configuration flags (abstract, placeholder, related)
  • Test ConfigAdmin readonly fields and menu_structure save logic
  • Cover SiteListFilter lookups and queryset filtering with and without params
  • Validate extension registration/unregistration and changeform_view scenarios
tests/test_admin.py
Introduce manager tests for djangocms_blog and djangocms_stories
  • Test tag filtering, tag list, tag cloud, and tag slugs
  • Verify site-based and admin-specific queryset methods
  • Cover GenericDateTaggedManager date aggregation (get_months) and on_site behavior
  • Include integration and edge-case tests combining filters and empty querysets
tests/test_managers.py
Add template tag tests for djangocms_stories
  • Test namespace_url tag with and without args and within links
  • Validate media_plugins and media_images extraction behaviors
  • Cover absolute_url in basic, language-specific, edit/preview modes, and None handling
  • Include integration scenarios and loop rendering of tags
tests/test_templatetags.py
Refactor GenericDateTaggedManager in djangocms_blog/managers.py
  • Remove deprecated wrapper methods (published, available, archived, etc.)
  • Add docstrings to filter_by_language and on_site convenience methods
djangocms_blog/managers.py
Clean up test factory definitions
  • Remove unused Site import and default_site variable
tests/factories.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We encountered an error and are unable to review this PR. We have been notified and are working to fix it.

You can try again by commenting this pull request with @sourcery-ai review, or contact us for help.

@fsbraun fsbraun closed this Nov 3, 2025
@codecov
Copy link

codecov bot commented Nov 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.57%. Comparing base (166a805) to head (ba8cca0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #54   +/-   ##
=======================================
  Coverage   86.57%   86.57%           
=======================================
  Files          23       23           
  Lines        2070     2070           
  Branches      232      232           
=======================================
  Hits         1792     1792           
  Misses        186      186           
  Partials       92       92           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants