-
-
Notifications
You must be signed in to change notification settings - Fork 100
Mazulo/adds faker generator feature #365
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
base: main
Are you sure you want to change the base?
Changes from all commits
a8ee4d2
1c91032
a3af865
461e8c4
76d07bb
9bcb424
77221e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,3 +14,4 @@ build/ | |
| lib64 | ||
| pyvenv.cfg | ||
| dist/ | ||
| .project | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| from typing import Callable, Dict | ||
|
|
||
| from faker import Faker | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This import (and its subsequent behavior) should be resilient to |
||
|
|
||
| FAKER = Faker() | ||
|
|
||
| faker_generator_mapping: Dict[str, Callable] = { | ||
| "username": FAKER.user_name, | ||
| "email": FAKER.email, | ||
| "first_name": FAKER.first_name, | ||
| "last_name": FAKER.last_name, | ||
| "name": FAKER.name, | ||
| "fullname": FAKER.name, | ||
| "full_name": FAKER.name, | ||
| "ip": FAKER.ipv4, | ||
| "ipv4": FAKER.ipv4, | ||
| "ipv6": FAKER.ipv6, | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| django>=3.2 | ||
| Faker==15.1.3 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this could be moved to |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See other comment about
ImportError. I think that if we fail to importfakerwe should output a warning message (when_use_faker_generatorisTrue) and continue past this logic so that it does not break, but still gives the user feedback that they are trying to use an optional feature for which they do not have all the requirements.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's cleaner to fail when someone tries to use the feature without installing faker.
But not using the feature should still be possible without faker being installed.
moving the
from .faker_gen import faker_generator_mappinginside this if clause should do the trick...?