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 'nailgun.entity_fields.URLField.gen_value' method always generates unique value #190

Merged
merged 1 commit into from
Aug 31, 2015

Conversation

oshtaier
Copy link
Contributor

+Removing corresponding workaround
+Removing redundant unit tests

names must be unique.
By default, :meth:`nailgun.entity_fields.StringField.gen_value` can
produce strings in both lower and upper cases, but domain name should
be always in lower case due logical reason.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this. I must've copied and pasted. Blech!

@Ichimonji10
Copy link
Contributor

ACK.

Fixes #189.

@abalakh
Copy link
Contributor

abalakh commented Aug 31, 2015

ACK

abalakh added a commit that referenced this pull request Aug 31, 2015
Make 'nailgun.entity_fields.URLField.gen_value' method always generates unique value
@abalakh abalakh merged commit 1105a2c into SatelliteQE:master Aug 31, 2015
@@ -265,4 +266,4 @@ class URLField(StringField):

def gen_value(self):
"""Return a value suitable for a :class:`URLField`."""
return gen_url()
return gen_url(subdomain=gen_alpha())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9gag and 4chan fans might get upset about this solution..how about this?

return gen_url(subdomain=gen_alphanumeric())

also, how about including a . to support multiple-domain format (like foo.bar.org)?
of course it must not be at the beginning or at the end of the string

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not restrict or introduce any limitation to possible URL, so if you like to use particular URL in your specific test case - just do it, but for generic scenario (for create_missing() method) I prefer to use most basic generator method, so it will be applicable for most possible situations

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rplevka You're right. It'd be good to generate more "interesting" data. I didn't both pushing for the change, though, because this PR really just works around issues in the underlying fauxfactory library. An even better solution is to make the gen_url function produce a greater variety of URLs and obey RFC 2606.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[...] this PR really just works around issues in the underlying fauxfactory library.

What are they? Is there an issue filed to track them?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@omaciel There's two issues:

  • gen_url, gen_email and possibly others generate real values that might be in use in the wild. For example, gen_url might spit out test.com.
  • gen_url doesn't produce especially random values. That's why we're calling gen_url(subdomain=gen_alpha()) instead of gen_url() here in NailGun.

omaciel/fauxfactory#26 is describes how gen_email produces "real" values. There aren't issues for the other methods that produce "real" values. There's not an issue for gen_url's lack of randomness.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@omaciel from my observation gen_url method give us not so many variations of inputs and such data become similar pretty fast. Let's say, it generate:
test.com, example.com, test.biz, example.biz and few more, so even for 10 tests there is chance that we will have duplicated entry. Using proposed approach we can decrease such chances in hundreds times

@elyezer
Copy link
Contributor

elyezer commented Aug 31, 2015

👍

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.

6 participants