Skip to content

Commit

Permalink
Remove duplicated comments and improve docstring of a few tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anapaulagomes committed Nov 17, 2019
1 parent 62c0b4b commit 95d13e4
Showing 1 changed file with 6 additions and 25 deletions.
31 changes: 6 additions & 25 deletions tests/test_baker.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,49 +179,33 @@ def test_dependent_models_with_ForeignKey(self):
assert isinstance(dog.owner, models.Person)

def test_foreign_key_on_parent_should_create_one_object(self):
"""
Foreign key on parent gets created twice. Once for
parent object and another time for child object
"""
person_count = models.Person.objects.count()
baker.make(models.GuardDog)
assert models.Person.objects.count() == person_count + 1

def test_foreign_key_on_parent_is_not_created(self):
"""
Foreign key on parent doesn't get created using owner
"""
"""Foreign key on parent doesn't get created using owner."""
owner = baker.make(models.Person)
person_count = models.Person.objects.count()
dog = baker.make(models.GuardDog, owner=owner)
assert models.Person.objects.count() == person_count
assert dog.owner == owner

def test_foreign_key_on_parent_id_is_not_created(self):
"""
Foreign key on parent doesn't get created using owner_id
"""
"""Foreign key on parent doesn't get created using owner_id."""
owner = baker.make(models.Person)
person_count = models.Person.objects.count()
dog = baker.make(models.GuardDog, owner_id=owner.id)
assert models.Person.objects.count() == person_count
assert models.GuardDog.objects.get(pk=dog.pk).owner == owner

def test_auto_now_add_on_parent_should_work(self):
"""
Foreign key on parent gets created twice. Once for
parent object and another time for child object
"""
person_count = models.Person.objects.count()
dog = baker.make(models.GuardDog)
assert models.Person.objects.count() == person_count + 1
assert dog.created

def test_attrs_on_related_model_through_parent(self):
"""
Foreign key on parent gets created twice. Once for
parent object and another time for child object
"""
baker.make(models.GuardDog, owner__name='john')
for person in models.Person.objects.all():
assert person.name == 'john'
Expand Down Expand Up @@ -285,9 +269,6 @@ def test_create_many_to_many_with_set_default_quantity(self):
assert store.customers.count() == baker.MAX_MANY_QUANTITY

def test_create_many_to_many_with_through_option(self):
"""
This does not works # FIXME
"""
# School student's attr is a m2m relationship with a model through
school = baker.make(models.School, make_m2m=True)
assert models.School.objects.count() == 1
Expand Down Expand Up @@ -618,11 +599,11 @@ def test_do_not_refresh_from_db_by_default(self):
class TestBakerMakeCanFetchInstanceFromDefaultManager():

def test_annotation_within_manager_get_queryset_are_run_on_make(self):
"""Test that a custom model Manager can be used within make().
"""A custom model Manager can be used within make().
Passing _from_manager='objects' will force baker.make() to
return an instance that has been going through that given
Manager, thus calling its get_queryset() method and associated
Passing ``_from_manager='objects'`` will force ``baker.make()``
to return an instance that has been going through a given
Manager, thus calling its ``get_queryset()`` method and associated
code, like default annotations. As such the instance will have
the same fields as one created in the application.
Expand Down

0 comments on commit 95d13e4

Please sign in to comment.