Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Jer-Sch committed Sep 22, 2021
1 parent b1961bb commit 5158dda
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 20 deletions.
3 changes: 3 additions & 0 deletions app/grants/tests/models/factories/clr_match_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pytest
from grants.models.clr_match import CLRMatch

from .contribution_factory import ContributionFactory
from .grant_factory import GrantFactory


Expand All @@ -14,3 +15,5 @@ class Meta:

amount = 0.0
grant = factory.SubFactory(GrantFactory)
test_payout_contribution = factory.SubFactory(ContributionFactory)
payout_contribution = factory.SubFactory(ContributionFactory)
13 changes: 13 additions & 0 deletions app/grants/tests/models/factories/contribution_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import factory
from grants.models.contribution import Contribution

from .subscription_factory import SubscriptionFactory


class ContributionFactory(factory.django.DjangoModelFactory):
"""Create mock Contribution for testing."""

class Meta:
model = Contribution

subscription = factory.SubFactory(SubscriptionFactory)
12 changes: 12 additions & 0 deletions app/grants/tests/models/factories/profile_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import factory
from dashboard.models import Profile


class ProfileFactory(factory.django.DjangoModelFactory):
"""Create mock Profile for testing."""

class Meta:
model = Profile

handle = factory.Sequence(lambda n: "Contributor_%03d" % n)
data = {}
15 changes: 15 additions & 0 deletions app/grants/tests/models/factories/subscription_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import factory
from grants.models.subscription import Subscription

from .grant_factory import GrantFactory
from .profile_factory import ProfileFactory


class SubscriptionFactory(factory.django.DjangoModelFactory):
"""Create mock Subscription for testing."""

class Meta:
model = Subscription

grant = factory.SubFactory(GrantFactory)
contributor_profile = factory.SubFactory(ProfileFactory)
36 changes: 16 additions & 20 deletions app/grants/tests/models/test_clr_match.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
from grants.models.clr_match import CLRMatch
from grants.models.contribution import Contribution
from grants.models.grant import Grant

from .factories.clr_match_factory import CLRMatchFactory
Expand All @@ -17,103 +18,98 @@ def test_creation(self):
assert isinstance(clr_match, CLRMatch)

def test_clr_match_has_round_number(self):
"""Test 'round_number' attribute and default value."""
"""Test 'round_number' attribute is present."""

clr_match = CLRMatchFactory()

assert hasattr(clr_match, 'round_number')
assert clr_match.round_number == None

def test_clr_match_has_amount(self):
"""Test 'amount' attribute and default value."""
"""Test 'amount' attribute is present and is a float."""

clr_match = CLRMatchFactory()

assert hasattr(clr_match, 'amount')
assert clr_match.amount == 0.0

def test_clr_match_has_an_associated_grant(self):
"""Test CLRMatch has an associated grant."""
"""Test 'grant' attribute is present and is an instance of Grant."""

clr_match = CLRMatchFactory()

assert hasattr(clr_match, 'grant')
assert isinstance(clr_match.grant, Grant)

def test_clr_match_has_a_has_passed_kyc_attribute(self):
"""Test 'has_passed_kyc' attribute and default value."""
"""Test 'has_passed_kyc' attribute is present and defaults to False."""

clr_match = CLRMatchFactory()

assert hasattr(clr_match, 'has_passed_kyc')
assert clr_match.has_passed_kyc == False

def test_clr_match_has_a_ready_for_test_payout_attribute(self):
"""Test 'ready_for_test_payout' attribute and default value."""
"""Test 'ready_for_test_payout' attribute is present and defaults to False."""

clr_match = CLRMatchFactory()

assert hasattr(clr_match, 'ready_for_test_payout')
assert clr_match.ready_for_test_payout == False

def test_clr_match_has_a_test_payout_tx(self):
"""Test 'test_payout_tx' attribute and default value."""
"""Test 'test_payout_tx' attribute is present."""

clr_match = CLRMatchFactory()

assert hasattr(clr_match, 'test_payout_tx')
assert clr_match.test_payout_tx == ''

def test_clr_match_has_a_test_payout_tx_date(self):
"""Test 'test_payout_tx_date' attribute and default value."""
"""Test 'test_payout_tx_date' attribute is present."""

clr_match = CLRMatchFactory()

assert hasattr(clr_match, 'test_payout_tx_date')
assert clr_match.test_payout_tx_date == None

def test_clr_match_has_a_test_payout_contribution(self):
"""Test 'test_payout_contribution' attribute."""
"""Test 'test_payout_contribution' attribute is present and is an instance of Contribution."""

clr_match = CLRMatchFactory()

assert hasattr(clr_match, 'test_payout_contribution')
assert clr_match.test_payout_contribution == None
assert isinstance(clr_match.test_payout_contribution, Contribution)

def test_clr_match_has_a_ready_for_payout_attribute(self):
"""Test 'ready_for_payout' attribute and default value."""
"""Test 'ready_for_payout' attribute is present and defaults to False."""

clr_match = CLRMatchFactory()

assert hasattr(clr_match, 'ready_for_payout')
assert clr_match.ready_for_payout == False

def test_clr_match_has_payout_tx(self):
"""Test 'payout_tx' attribute and default value."""
"""Test 'payout_tx' attribute is present."""

clr_match = CLRMatchFactory()

assert hasattr(clr_match, 'payout_tx')
assert clr_match.payout_tx == ''

def test_clr_match_has_payout_tx_date(self):
"""Test 'payout_tx_date' attribute."""
"""Test 'payout_tx_date' attribute is present."""

clr_match = CLRMatchFactory()

assert hasattr(clr_match, 'payout_tx_date')
assert clr_match.payout_tx_date == None

def test_clr_match_has_payout_contribution_attribute(self):
"""Test 'payout_contribution' attribute."""
"""Test 'payout_contribution' attribute is present and is an instance of Contribution."""

clr_match = CLRMatchFactory()

assert hasattr(clr_match, 'payout_contribution')
assert clr_match.payout_contribution == None
assert isinstance(clr_match.payout_contribution, Contribution)

def test_clr_match_has_comments(self):
"""Test 'comments' attribute and default value."""
"""Test 'comments' attribute is present and defaults to empty string."""

clr_match = CLRMatchFactory()

Expand Down

0 comments on commit 5158dda

Please sign in to comment.