diff --git a/app/grants/tests/models/factories/clr_match_factory.py b/app/grants/tests/models/factories/clr_match_factory.py index 8ebfea17e26..d1af24135ba 100644 --- a/app/grants/tests/models/factories/clr_match_factory.py +++ b/app/grants/tests/models/factories/clr_match_factory.py @@ -2,6 +2,7 @@ import pytest from grants.models.clr_match import CLRMatch +from .contribution_factory import ContributionFactory from .grant_factory import GrantFactory @@ -14,3 +15,5 @@ class Meta: amount = 0.0 grant = factory.SubFactory(GrantFactory) + test_payout_contribution = factory.SubFactory(ContributionFactory) + payout_contribution = factory.SubFactory(ContributionFactory) diff --git a/app/grants/tests/models/factories/contribution_factory.py b/app/grants/tests/models/factories/contribution_factory.py new file mode 100644 index 00000000000..3d8505dc11e --- /dev/null +++ b/app/grants/tests/models/factories/contribution_factory.py @@ -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) \ No newline at end of file diff --git a/app/grants/tests/models/factories/profile_factory.py b/app/grants/tests/models/factories/profile_factory.py new file mode 100644 index 00000000000..f0d4a27423c --- /dev/null +++ b/app/grants/tests/models/factories/profile_factory.py @@ -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 = {} \ No newline at end of file diff --git a/app/grants/tests/models/factories/subscription_factory.py b/app/grants/tests/models/factories/subscription_factory.py new file mode 100644 index 00000000000..aab72b01bb8 --- /dev/null +++ b/app/grants/tests/models/factories/subscription_factory.py @@ -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) \ No newline at end of file diff --git a/app/grants/tests/models/test_clr_match.py b/app/grants/tests/models/test_clr_match.py index 3c4ed5e97a0..4c399b61567 100644 --- a/app/grants/tests/models/test_clr_match.py +++ b/app/grants/tests/models/test_clr_match.py @@ -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 @@ -17,15 +18,14 @@ 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() @@ -33,7 +33,7 @@ def test_clr_match_has_amount(self): 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() @@ -41,7 +41,7 @@ def test_clr_match_has_an_associated_grant(self): 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() @@ -49,7 +49,7 @@ def test_clr_match_has_a_has_passed_kyc_attribute(self): 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() @@ -57,31 +57,29 @@ def test_clr_match_has_a_ready_for_test_payout_attribute(self): 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() @@ -89,31 +87,29 @@ def test_clr_match_has_a_ready_for_payout_attribute(self): 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()