Skip to content

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
Contributor

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
Contributor

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
Contributor

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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.

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
Contributor

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

@qlty-cloud-legacy
Copy link

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