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

Added a factory file for the Category Model #1496

Merged
merged 8 commits into from
Feb 19, 2023

Conversation

Nehemiah60
Copy link
Contributor

Closes #1350

Description

Created a factory file for the Category model.

class Meta:
model = Category

name = factory.Faker("name")
Copy link
Member

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

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
name = factory.Faker("name")
name = factory.Faker("lorem")

Comment on lines 13 to 15
categories = CategoryFactory.create_batch(10)
for category in categories:
print(category.name)
Copy link
Member

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.

Suggested change
categories = CategoryFactory.create_batch(10)
for category in categories:
print(category.name)

Copy link
Contributor Author

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
Copy link

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
Copy link

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
Copy link

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/threads/factory.py Show resolved Hide resolved
for linked_civi in extracted:
self.linked_civis.add(linked_civi)

@factory.post_generation
Copy link

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 Show resolved Hide resolved
project/accounts/factory.py Show resolved Hide resolved
project/accounts/factory.py Show resolved Hide resolved
for tag in extracted:
self.tags.add(tag)

@factory.post_generation
Copy link

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.

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])
Copy link

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
Copy link

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
Copy link

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.

project/accounts/factory.py Show resolved Hide resolved
project/accounts/factory.py Show resolved Hide resolved
project/accounts/factory.py Show resolved Hide resolved
project/threads/factory.py Show resolved Hide resolved
project/threads/factory.py Show resolved Hide resolved
project/threads/factory.py Outdated Show resolved Hide resolved
project/threads/factory.py Show resolved Hide resolved
num_civis = 0
num_solutions = 0

@factory.post_generation
Copy link

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
Copy link

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
Copy link

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.

project/accounts/factory.py Show resolved Hide resolved
for category in extracted:
self.categories.add(category)

@factory.post_generation
Copy link

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.

project/accounts/factory.py Show resolved Hide resolved
num_civis = 0
num_solutions = 0

@factory.post_generation
Copy link

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.

project/accounts/factory.py Show resolved Hide resolved
project/accounts/factory.py Show resolved Hide resolved
project/accounts/factory.py Show resolved Hide resolved
num_civis = 0
num_solutions = 0

@factory.post_generation
Copy link

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 Show resolved Hide resolved
@@ -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])
Copy link
Member

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?

Suggested change
is_verified = factory.fuzzy.FuzzyChoice(choices=[False, False])
is_verified = factory.fuzzy.FuzzyChoice(choices=[True, False])

Copy link
Contributor Author

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

@codeclimate
Copy link

codeclimate bot commented Feb 13, 2023

Code Climate has analyzed commit 1345209 and detected 9 issues on this pull request.

Here's the issue category breakdown:

Category Count
Duplication 9

View more on Code Climate.

@brylie brylie merged commit 05137fa into CiviWiki:develop Feb 19, 2023
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.

add development fixtures
2 participants