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

Make has_submenu_items a property (for programatically setting option) #401

Closed
schlich opened this issue Aug 27, 2021 · 1 comment
Closed

Comments

@schlich
Copy link
Contributor

schlich commented Aug 27, 2021

Hi,

I am spinning up some fake data for my site using FactoryBoy/faker, including Wagtail Menus. I noticed that MenuPage objects have the has_submenu_items getter method, but I would like to programatically set this option from a python script.

I am guessing it would be a trivial fix to make the method a property instead.

If this seems plausible, i'd be happy to attempt a PR.

(maybe this is implemented in the Wagtail Menus API #302 ? )

@ababic
Copy link
Collaborator

ababic commented Sep 6, 2021

@schlich I'm not sure changing code to facilitate such a test is the best idea. Plus, making it a 'property' would not make the value settable unless you used cached_property, or added a dedicated setter method, neither of which do I think fit the design very well.

If you do need to control the method result, why not update your factory to replace the method on the instances it creates? The unittest.mock library in python core is perfect for this kind of thing.

@ababic ababic closed this as completed Sep 9, 2021
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

No branches or pull requests

2 participants