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

Mocks of ListType ignore field 'choices' parameter #581

Open
festinuz opened this issue Jan 9, 2019 · 0 comments
Open

Mocks of ListType ignore field 'choices' parameter #581

festinuz opened this issue Jan 9, 2019 · 0 comments

Comments

@festinuz
Copy link

festinuz commented Jan 9, 2019

Python 3.6.6
Schematics 2.1.0

ListField ignores choices parameter of underlying field when creating mock object. Here is minimal code that reproduces error:

from schematics.types import StringType, ListType
from schematics.models import Model


class Foo(Model):
    bar = StringType(choices=["lol", "kek"], required=True)
    baz = ListType(StringType(choices=["lol", "kek"]), required=True)


print(Foo.get_mock_object().to_primitive())
# >> {'bar': 'kek', 'baz': ['mwhot1h', '57kMabXP', 'koMg', 'GBtlbJQvT', '']}

It seems to work fine with params like max_length though, so i don't know what the deal is. Have i just missed something that's specified in docs?

With current behavior, objects generated by mocking fail to validate against model, which is frustrating.

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

1 participant