Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6/Test GrantCategory #9397

Merged
merged 6 commits into from
Sep 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/grants/models/clr_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ class CLRMatch(SuperModel):

def __str__(self):
"""Return the string representation of a Grant."""
return f"id: {self.pk}, grant: {self.grant.pk}, round: {self.round_number}, amount: {self.amount}"
return f"id: {self.pk}, grant: {self.grant.pk}, round: {self.round_number}, amount: {self.amount}"
1 change: 1 addition & 0 deletions app/grants/models/contribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Contribution(SuperModel):
CHECKOUT_TYPES = [
('eth_std', 'eth_std'),
('eth_zksync', 'eth_zksync'),
('eth_polygon', 'eth_polygon'),
Copy link
Member

@thelostone-mc thelostone-mc Sep 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh this is def needed piece ! @chibie

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh shit! all my polygon backend changes in former models.py (https://github.com/gitcoinco/web/blob/5901de79753445f0c76cd406f49154186e0e80d7/app/grants/models.py) are missing from contribution.py in master!! 😕

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chibie Oh no! I thought I had updated it with all the changes 😞

('zcash_std', 'zcash_std'),
('celo_std', 'celo_std'),
('zil_std', 'zil_std'),
Expand Down
3 changes: 1 addition & 2 deletions app/grants/models/grant.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ class Meta:
)

in_active_clrs = models.ManyToManyField(
GrantCLR,
"GrantCLR",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be in ""

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea... i guess it's for lazy loading to prevent circular import

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that's right @chibie

help_text="Active Grants CLR Round"
)
is_clr_active = models.BooleanField(default=False, help_text=_('CLR Round active or not? (auto computed)'))
Expand Down Expand Up @@ -885,7 +885,6 @@ def save(self, update=True, *args, **kwargs):

self.clr_prediction_curve = self.calc_clr_prediction_curve
self.clr_round_num = self.calc_clr_round_label

self.search_vector = (
SearchVector('title', weight='A') + SearchVector('description', weight='B')
)
Expand Down
2 changes: 1 addition & 1 deletion app/grants/models/match_pledge.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ def data_json(self):

def __str__(self):
"""Return the string representation of this object."""
return f"{self.profile} <> {self.amount} DAI"
return f"{self.profile} <> {self.amount} DAI"
2 changes: 1 addition & 1 deletion app/grants/models/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,4 +554,4 @@ def create_contribution(self, tx_id, is_successful_contribution=True):
successful_contribution(self.grant, self, contribution)

update_grant_metadata.delay(self.pk)
return contribution
return contribution
Empty file.
Empty file.
9 changes: 9 additions & 0 deletions app/grants/tests/models/factories/grant_category_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import factory
from grants.models.grant_category import GrantCategory


class GrantCategoryFactory(factory.django.DjangoModelFactory):
"""Create mock GrantCategory for testing."""

class Meta:
model = GrantCategory
23 changes: 23 additions & 0 deletions app/grants/tests/models/test_grant_category.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import pytest
from grants.models.grant_category import GrantCategory

from .factories.grant_category_factory import GrantCategoryFactory


@pytest.mark.django_db
class TestGrantCategory:
"""Test GrantCategory model."""

def test_creation(self):
"""Test GrantCategory returned by factory is valid."""

grant_category = GrantCategoryFactory()

assert isinstance(grant_category, GrantCategory)

def test_grant_category_has_a_category(self):
"""Test 'category' attribute is present."""

grant_category = GrantCategoryFactory()

assert hasattr(grant_category, 'category')
1 change: 1 addition & 0 deletions requirements/test.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-r base.txt
pytest==6.2.4
pytest-cov==2.12.0
pytest-factoryboy==2.1.0
pytest-isort==2.0.0
pytest-django==4.3.0
pytest-sugar==0.9.4
Expand Down