Skip to content
This repository has been archived by the owner on Oct 22, 2019. It is now read-only.

Option of "Integer generator" generate only positive numbers #351

Closed
aipi opened this issue Dec 28, 2017 · 1 comment
Closed

Option of "Integer generator" generate only positive numbers #351

aipi opened this issue Dec 28, 2017 · 1 comment

Comments

@aipi
Copy link

aipi commented Dec 28, 2017

I am creating a test with mommy where a apply it to generate numbers of an attribute and after that, to do a request.

The piece of the test:

channel = mommy.make(Channel)

request = self.client.get(
            reverse('core:add_number_to_channel',
                    args=[self.channel.asn.number,
                          self.channel.uuid]))

Message raised:

E django.urls.exceptions.NoReverseMatch: Reverse for 'add_asn_to_channel' with arguments '(-1422, UUID('fdb36645-937c-4c4c-b78d-1ca981dc42a5'))' and keyword arguments '{}' not found. 1 pattern(s) tried: ['core/form/add-asn-to-channel/(?P<asn>[\\d]+)/(?P<channel>[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})/$']

/usr/local/lib/python3.5/site-packages/django/urls/resolvers.py:392: NoReverseMatch

I do not instance ASN and pass to Channel, because of model-mommy already treat it for me, instancing this dependency and generating random integers (-1422 in this case of the raised message), once that ASN is a foreign key of Channel. It could work normally, however ASN.number has a validator to accept only positive numbers. It turns my test unpredictable to know if the number is positive or negative. Does exist a way for the treat it without the necessity of using a third party tool (I swear that I still did not think how would do it) or without instance ASN with a fixed positive number value? Does mommy take care of this kind of cases?

@berinhard
Copy link
Owner

@aipi by default model mommy does not take care of this kind of cases. But there are ways you can solve this:

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

No branches or pull requests

2 participants