-
Notifications
You must be signed in to change notification settings - Fork 344
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
Added a factory file for the Category Model #1496
Conversation
project/categories/factory.py
Outdated
class Meta: | ||
model = Category | ||
|
||
name = factory.Faker("name") |
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.
The ´name´factory is used to generate names or people. Let's use Faker factory ´lorem´ here, since it is more like a keyword.
https://faker.readthedocs.io/en/master/providers/faker.providers.lorem.html
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.
name = factory.Faker("name") | |
name = factory.Faker("lorem") |
project/categories/factory.py
Outdated
categories = CategoryFactory.create_batch(10) | ||
for category in categories: | ||
print(category.name) |
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 don't think we want to add these lines, since we will want to generate the fake content via a manual command.
categories = CategoryFactory.create_batch(10) | |
for category in categories: | |
print(category.name) |
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.
Thanks, @brylie. I will work on it. If you get time, please you can also review the other PR, I mentioned. Thanks.
num_civis = 0 | ||
num_solutions = 0 | ||
|
||
@factory.post_generation |
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.
Similar blocks of code found in 9 locations. Consider refactoring.
for fact in extracted: | ||
self.facts.add(fact) | ||
|
||
@factory.post_generation |
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.
Similar blocks of code found in 9 locations. Consider refactoring.
for tag in extracted: | ||
self.tags.add(tag) | ||
|
||
@factory.post_generation |
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.
Similar blocks of code found in 9 locations. Consider refactoring.
for linked_civi in extracted: | ||
self.linked_civis.add(linked_civi) | ||
|
||
@factory.post_generation |
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.
Similar blocks of code found in 9 locations. Consider refactoring.
for tag in extracted: | ||
self.tags.add(tag) | ||
|
||
@factory.post_generation |
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.
Similar blocks of code found in 9 locations. Consider refactoring.
project/accounts/factory.py
Outdated
first_name = factory.Faker("lorem") | ||
last_name = factory.Faker("lorem") | ||
about_me = factory.Faker("lorem") | ||
is_verified = factory.fuzzy.FuzzyChoice(choices=[False, False, False, False]) |
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.
Line too long (81 > 79 characters)
num_civis = 0 | ||
num_solutions = 0 | ||
|
||
@factory.post_generation |
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.
Similar blocks of code found in 5 locations. Consider refactoring.
votes_pos = 0 | ||
votes_vpos = 0 | ||
|
||
@factory.post_generation |
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.
Similar blocks of code found in 5 locations. Consider refactoring.
num_civis = 0 | ||
num_solutions = 0 | ||
|
||
@factory.post_generation |
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.
Similar blocks of code found in 6 locations. Consider refactoring.
for fact in extracted: | ||
self.facts.add(fact) | ||
|
||
@factory.post_generation |
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.
Similar blocks of code found in 6 locations. Consider refactoring.
for tag in extracted: | ||
self.tags.add(tag) | ||
|
||
@factory.post_generation |
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.
Similar blocks of code found in 6 locations. Consider refactoring.
for category in extracted: | ||
self.categories.add(category) | ||
|
||
@factory.post_generation |
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.
Similar blocks of code found in 6 locations. Consider refactoring.
num_civis = 0 | ||
num_solutions = 0 | ||
|
||
@factory.post_generation |
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.
Similar blocks of code found in 4 locations. Consider refactoring.
num_civis = 0 | ||
num_solutions = 0 | ||
|
||
@factory.post_generation |
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.
Similar blocks of code found in 2 locations. Consider refactoring.
project/accounts/factory.py
Outdated
@@ -20,7 +20,7 @@ class Meta: | |||
first_name = factory.Faker("lorem") | |||
last_name = factory.Faker("lorem") | |||
about_me = factory.Faker("lorem") | |||
is_verified = factory.fuzzy.FuzzyChoice(choices=[False, False, False, False]) | |||
is_verified = factory.fuzzy.FuzzyChoice(choices=[False, False]) |
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.
Should this also allow True
?
is_verified = factory.fuzzy.FuzzyChoice(choices=[False, False]) | |
is_verified = factory.fuzzy.FuzzyChoice(choices=[True, False]) |
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 was not so sure. Because the field had False as a default value. But I will make the changes @brylie
Code Climate has analyzed commit 1345209 and detected 9 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
Closes #1350
Description
Created a factory file for the Category model.