Skip to content

Commit

Permalink
Merge pull request #5 from jrobichaud/upgrade-requirements
Browse files Browse the repository at this point in the history
Upgrade requirements
  • Loading branch information
jrobichaud authored Apr 6, 2019
2 parents 19accbc + 86a6801 commit d19a9d0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Django==2.0.1
Django>=1.11,<2
factory-boy==2.8.1
Faker==0.9.1
factory-boy==2.11.1
Faker==1.0.2

-r testing_migrations/requirements.txt
28 changes: 14 additions & 14 deletions tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,6 @@ class EntryFactory(factory.DjangoModelFactory):
class Meta:
model = models.Entry

class Params:
with_authors = factory.Trait(
authors=factory.LazyFunction(
lambda: tuple(
AuthorFactory.create_batch(random.randint(1, 10))
)
)
)

blog = factory.SubFactory(BlogFactory)
headline = factory.Faker('sentence', nb_words=4)
body_text = factory.Faker('paragraphs', nb=4)
Expand All @@ -62,16 +53,25 @@ class Params:
)
)

@factory.post_generation
def with_authors(self, create, extracted, **kwargs):
if extracted and create:
EntryFactory.create_authors(
self,
create,
AuthorFactory.create_batch(random.randint(1, 10))
)

@factory.post_generation
def authors(self, create, extracted, **kwargs):
if not create:
# Simple build, do nothing.
return
EntryFactory.create_authors(self, create, extracted)

if extracted:
@staticmethod
def create_authors(obj, create, extracted):
if extracted and create:
# A list of authors were passed in, use them
for author in extracted:
self.authors.add(author)
obj.authors.add(author)

n_comments = factory.Faker('pyint')
n_pingbacks = factory.Faker('pyint')
Expand Down

0 comments on commit d19a9d0

Please sign in to comment.