-
-
Notifications
You must be signed in to change notification settings - Fork 775
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add test file and factory * add tests for total_donations, top_matching_partners, top_matching_partners_mobile, top_individual_donors, top_individual_donors_mobile * add tests for graduated_grantees_description, share_your_story_email, and is_published * add tests for HallOfFameGrantee attributes * remove extra lines * refactor
- Loading branch information
Jeremy Schuurmans
authored
Jan 11, 2022
1 parent
cea8a31
commit f2a0150
Showing
2 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import factory | ||
from grants.models.hall_of_fame import GrantHallOfFame, GrantHallOfFameGrantee | ||
|
||
|
||
class GrantHallOfFameFactory(factory.django.DjangoModelFactory): | ||
class Meta: | ||
model = GrantHallOfFame | ||
|
||
class GrantHallOfFameGranteeFactory(factory.django.DjangoModelFactory): | ||
class Meta: | ||
model = GrantHallOfFameGrantee | ||
|
||
hall_of_fame = factory.SubFactory(GrantHallOfFameFactory) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import pytest | ||
from grants.tests.factories.grant_hall_of_fame_factory import GrantHallOfFameFactory, GrantHallOfFameGranteeFactory | ||
from grants.models.hall_of_fame import GrantHallOfFame, GrantHallOfFameGrantee | ||
|
||
|
||
@pytest.mark.django_db | ||
class TestGrantHallOfFame: | ||
"""Test GrantHallOfFame class in GrantHallOfFame model.""" | ||
|
||
def test_creation(self): | ||
"""Test GrantHallOfFame data returned by factory is valid.""" | ||
|
||
grant_hall_of_fame = GrantHallOfFameFactory() | ||
|
||
assert isinstance(grant_hall_of_fame, GrantHallOfFame) | ||
|
||
def test_grant_hall_of_fame_has_total_donations(self): | ||
grant_hall_of_fame = GrantHallOfFameFactory() | ||
|
||
assert hasattr(grant_hall_of_fame, 'total_donations') | ||
|
||
def test_grant_hall_of_fame_has_top_matching_partners(self): | ||
grant_hall_of_fame = GrantHallOfFameFactory() | ||
|
||
assert hasattr(grant_hall_of_fame, 'top_matching_partners') | ||
|
||
def test_grant_hall_of_fame_has_top_matching_partners_mobile_attribute(self): | ||
grant_hall_of_fame = GrantHallOfFameFactory() | ||
|
||
assert hasattr(grant_hall_of_fame, 'top_matching_partners_mobile') | ||
|
||
def test_grant_hall_of_fame_has_top_individual_donors(self): | ||
grant_hall_of_fame = GrantHallOfFameFactory() | ||
|
||
assert hasattr(grant_hall_of_fame, 'top_individual_donors') | ||
|
||
def test_grant_hall_of_fame_has_top_individual_donors_mobile(self): | ||
grant_hall_of_fame = GrantHallOfFameFactory() | ||
|
||
assert hasattr(grant_hall_of_fame, 'top_individual_donors_mobile') | ||
|
||
def test_grant_hall_of_fame_has_graduated_grantees_description(self): | ||
grant_hall_of_fame = GrantHallOfFameFactory() | ||
|
||
assert hasattr(grant_hall_of_fame, 'graduated_grantees_description') | ||
|
||
def test_grant_hall_of_fame_has_share_your_story_email(self): | ||
grant_hall_of_fame = GrantHallOfFameFactory() | ||
|
||
assert hasattr(grant_hall_of_fame, 'share_your_story_email') | ||
|
||
def test_grant_has_is_published_attribute(self): | ||
grant_hall_of_fame = GrantHallOfFameFactory() | ||
|
||
assert hasattr(grant_hall_of_fame, 'is_published') | ||
assert grant_hall_of_fame.is_published == False | ||
|
||
@pytest.mark.django_db | ||
class TestGrantHallOfFameGrantee: | ||
"""Test GrantHallOfFameGrantee class in GrantHallOfFame model.""" | ||
|
||
def test_creation(self): | ||
"""Test GrantHallOfFameGrantee data returned by factory is valid.""" | ||
|
||
grant_hall_of_fame_grantee = GrantHallOfFameGranteeFactory() | ||
|
||
assert isinstance(grant_hall_of_fame_grantee, GrantHallOfFameGrantee) | ||
|
||
def test_grant_hall_of_fame_grantee_has_associated_hall_of_fame(self): | ||
grant_hall_of_fame_grantee = GrantHallOfFameGranteeFactory() | ||
|
||
assert hasattr(grant_hall_of_fame_grantee, 'hall_of_fame') | ||
|
||
def test_grant_hall_of_fame_grantee_has_grantee(self): | ||
grant_hall_of_fame_grantee = GrantHallOfFameGranteeFactory() | ||
|
||
assert hasattr(grant_hall_of_fame_grantee, 'grantee') | ||
|
||
def test_grant_hall_of_fame_grantee_has_a_name(self): | ||
grant_hall_of_fame_grantee = GrantHallOfFameGranteeFactory() | ||
|
||
assert hasattr(grant_hall_of_fame_grantee, 'name') | ||
|
||
def test_grant_hall_of_fame_grantee_has_funded_by_attribute(self): | ||
grant_hall_of_fame_grantee = GrantHallOfFameGranteeFactory() | ||
|
||
assert hasattr(grant_hall_of_fame_grantee, 'funded_by') | ||
|
||
def test_grant_hall_of_fame_grantee_has_an_amount(self): | ||
grant_hall_of_fame_grantee = GrantHallOfFameGranteeFactory() | ||
|
||
assert hasattr(grant_hall_of_fame_grantee, 'amount') | ||
|
||
def test_grant_hall_of_fame_grantee_has_a_description(self): | ||
grant_hall_of_fame_grantee = GrantHallOfFameGranteeFactory() | ||
|
||
assert hasattr(grant_hall_of_fame_grantee, 'description') | ||
|
||
def test_grant_hall_of_fame_grantee_has_accomplishment_1(self): | ||
grant_hall_of_fame_grantee = GrantHallOfFameGranteeFactory() | ||
|
||
assert hasattr(grant_hall_of_fame_grantee, 'accomplishment_1') | ||
|
||
def test_grant_hall_of_fame_grantee_has_accomplishment_2(self): | ||
grant_hall_of_fame_grantee = GrantHallOfFameGranteeFactory() | ||
|
||
assert hasattr(grant_hall_of_fame_grantee, 'accomplishment_2') |