Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Replace django mptt with django tree queries for tests #684

Conversation

kwongtn
Copy link
Contributor

@kwongtn kwongtn commented Jan 2, 2025

Description

As mentioned here, django-mptt is no longer supported.

This PR removes all references to django-mptt (and hence mptt in general) and replace it with treenode (or TreeNode, depending on context).

Should not have any effect on other code.

Merge the following first:

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Documentation

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

Summary by Sourcery

Replace django-mptt with tree_queries.

Enhancements:

  • Use TreeNode instead of MPTT.

Tests:

  • Update tests to use TreeNode.

kwongtn and others added 11 commits December 30, 2024 19:11
Signed-off-by: Kwong Tung Nan <[email protected]>
Signed-off-by: Kwong Tung Nan <[email protected]>
Signed-off-by: Kwong Tung Nan <[email protected]>
Co-authored-by: Thiago Bellini Ribeiro <[email protected]>
Co-authored-by: Thiago Bellini Ribeiro <[email protected]>
Signed-off-by: Kwong Tung Nan <[email protected]>
Signed-off-by: Kwong Tung Nan <[email protected]>
Signed-off-by: Kwong Tung Nan <[email protected]>
Copy link
Contributor

sourcery-ai bot commented Jan 2, 2025

Reviewer's Guide by Sourcery

This PR removes django-mptt and replaces it with treenode for enhanced performance and maintainability. The changes are primarily focused on updating model definitions, type annotations, and tests to reflect this shift.

Class diagram showing the transition from MPTT to TreeNode

classDiagram
    class MPTTModel {
        <<removed>>
        +parent
        +level
        +tree_id
        +lft
        +rght
    }

    class TreeNodeModel {
        <<added>>
        +parent
        +path
        +depth
        +ordering
    }

    note for TreeNodeModel "Replacement for MPTT implementation"
    MPTTModel <|-- TreeNodeModel : replaces
Loading

File-Level Changes

Change Details Files
Replaced MPTT models and types with TreeNode equivalents.
  • Updated model definitions to use TreeNode instead of MPTT.
  • Updated type annotations to reflect the model changes.
  • Refactored tests to use TreeNode-based models and connections.
  • Renamed files and directories to match the new naming convention.
tests/relay/mptt/models.py
tests/relay/treenode/models.py
tests/relay/mptt/a.py
tests/relay/treenode/a.py
tests/relay/mptt/b.py
tests/relay/treenode/b.py
tests/relay/mptt/test_nested_children.py
tests/relay/treenode/test_nested_children.py
tests/relay/mptt/test_lazy_annotations.py
tests/relay/treenode/test_lazy_annotations.py
tests/relay/mptt/snapshots/test_lazy_annotations/test_lazy_type_annotations_in_schema/authors_and_books_schema.gql
tests/relay/treenode/snapshots/test_lazy_annotations/test_lazy_type_annotations_in_schema/authors_and_books_schema.gql
Removed django-mptt dependency.
  • Removed django-mptt from pyproject.toml and poetry.lock files.
pyproject.toml
poetry.lock

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.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a 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. You can also use
    this command to specify where the summary should be inserted.

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

@codecov-commenter
Copy link

codecov-commenter commented Jan 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.00%. Comparing base (d55d956) to head (82e0f1d).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #684   +/-   ##
=======================================
  Coverage   89.00%   89.00%           
=======================================
  Files          42       42           
  Lines        3821     3821           
=======================================
  Hits         3401     3401           
  Misses        420      420           

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

@kwongtn kwongtn mentioned this pull request Jan 2, 2025
11 tasks
@bellini666
Copy link
Member

#683 got merged, can you rebase?

@kwongtn kwongtn marked this pull request as ready for review January 4, 2025 06:14
@kwongtn
Copy link
Contributor Author

kwongtn commented Jan 4, 2025

@bellini666 done 😁

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.

Hey @kwongtn - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Member

@bellini666 bellini666 left a comment

Choose a reason for hiding this comment

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

Noice! ❤️

@bellini666 bellini666 changed the title Remove django mptt replace with django tree queries test: Replace django mptt with django tree queries for tests Jan 4, 2025
@bellini666 bellini666 merged commit 0b28264 into strawberry-graphql:main Jan 4, 2025
28 checks passed
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