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

Use of traits with StreamBlockFactory #60

Open
jams2 opened this issue Jul 28, 2022 · 0 comments
Open

Use of traits with StreamBlockFactory #60

jams2 opened this issue Jul 28, 2022 · 0 comments

Comments

@jams2
Copy link
Contributor

jams2 commented Jul 28, 2022

Given a factory definition of

class LinkStreamBlockFactory(wagtail_factories.StreamBlockFactory):
    internal = factory.SubFactory(PageStructBlockFactory)
    document = factory.SubFactory(DocumentStructBlockFactory)
    external = factory.SubFactory(ExternalLinkStructBlockFactory)

    class Meta:
        model = blocks.LinkStreamBlock

    class Params:
        is_internal = factory.Trait(**{"0": "internal"})

it is not possible to use the is_internal trait, like LinkStreamBlockFactory(is_internal=True), as the is_internal keyword breaks StreamBlockFactory's parameter parsing. This particular use case is somewhat pointless (you could just call LinkStreamBlockFactory(**{"0": "internal"})), but there may be valid use cases for traits (maybe as defining a shorthand for a particular combination of nested options). I would like to hear opinions on this - would fixing this be useful?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant