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

Add set method to MockSet #185

Merged
merged 1 commit into from
Sep 8, 2024
Merged

Conversation

nfantone
Copy link
Contributor

@nfantone nfantone commented Sep 8, 2024

Currently, trying to mock the following scenario raises an AttributeError.

class Other(models.Model): ...

class MyModel(models.Model):
    others = models.ManyToManyField("Other", through="OtherModel")

with mocked_relations(MyModel, Other):
    model = MyModel.objects.get(id=1234)
    model.others.set([]) # AttributeError: Mock object has no attribute 'set'`.

This PR adds a mock implementation for RelatedManager.set field, supporting the above use case.

@nfantone nfantone force-pushed the mockset-set branch 2 times, most recently from 3158cf2 to 9be05ba Compare September 8, 2024 12:48
@codecov-commenter
Copy link

codecov-commenter commented Sep 8, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.68%. Comparing base (8f1448c) to head (ec67f77).
Report is 17 commits behind head on master.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #185   +/-   ##
=======================================
  Coverage   99.68%   99.68%           
=======================================
  Files           7        7           
  Lines         952      956    +4     
=======================================
+ Hits          949      953    +4     
  Misses          3        3           

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

@stefan6419846 stefan6419846 merged commit e7d8c41 into stphivos:master Sep 8, 2024
16 checks passed
@nfantone nfantone deleted the mockset-set branch September 9, 2024 16:28
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