-
-
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.
Jeremy/GITC-460/inaccurate payout amount bug (#9645)
* render payout_amount instead of token_value * normalize payout_amount to remove the trailing zeros * add tests for successful bounty api request, and successful bounty payout
- Loading branch information
Jeremy Schuurmans
authored
Nov 4, 2021
1 parent
8f40afc
commit 3ff30b5
Showing
6 changed files
with
81 additions
and
2 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
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
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,15 @@ | ||
from datetime import datetime, timedelta | ||
|
||
import factory | ||
from dashboard.models import Bounty | ||
|
||
|
||
class BountyFactory(factory.django.DjangoModelFactory): | ||
class Meta: | ||
model = Bounty | ||
|
||
web3_created = datetime.now() | ||
is_open = True | ||
expires_date = datetime.now() + timedelta(days=365) | ||
raw_data = {} | ||
bounty_owner_github_username = 'gitcoin' |
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 dashboard.models import BountyFulfillment | ||
from .bounty_factory import BountyFactory | ||
from .profile_factory import ProfileFactory | ||
|
||
|
||
class FulfillmentFactory(factory.django.DjangoModelFactory): | ||
class Meta: | ||
model = BountyFulfillment | ||
|
||
bounty = factory.SubFactory(BountyFactory) | ||
profile = factory.SubFactory(ProfileFactory) |
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,16 @@ | ||
import pytest | ||
from dashboard.tests.factories.bounty_factory import BountyFactory | ||
from rest_framework.test import APIClient | ||
|
||
|
||
class TestBountyAPI: | ||
def test_retrieves_activities(self, django_user_model): | ||
github_url = {'github_url': 'https://github.com/gitcoinco/web/issues/1'} | ||
BountyFactory(**github_url) | ||
user = django_user_model.objects.create(username="gitcoin", password="password123") | ||
client = APIClient() | ||
|
||
client.force_login(user) | ||
response = client.get('/actions/api/v0.1/bounty/', github_url, format='json') | ||
|
||
assert response.status_code == 200 |
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,34 @@ | ||
import pytest | ||
from dashboard.tests.factories.profile_factory import ProfileFactory | ||
from dashboard.tests.factories.bounty_factory import BountyFactory | ||
from dashboard.tests.factories.fulfillment_factory import FulfillmentFactory | ||
from rest_framework.test import APIClient | ||
|
||
|
||
@pytest.mark.django_db | ||
class TestBountyPayout: | ||
def test_pays_out_bounty(self, django_user_model): | ||
github_url = {'github_url': 'https://github.com/gitcoinco/web/issues/1'} | ||
BountyFactory(**github_url) | ||
user = django_user_model.objects.create(username="gitcoin", password="password123") | ||
ProfileFactory(user=user) | ||
fulfillment = FulfillmentFactory() | ||
|
||
client = APIClient() | ||
|
||
client.force_login(user) | ||
|
||
payload = { | ||
'payout_type': 'fiat', | ||
'tenant': 'testtenant', | ||
'amount': '1', | ||
'token_name': 'ETH', | ||
'funder_address': '0x0', | ||
'payout_status': 'pending', | ||
'funder_identifier': 'test_funder_identifier', | ||
'payout_tx_id': '0x0', | ||
} | ||
|
||
response = client.post(f'/api/v1/bounty/payout/{fulfillment.id}', payload) | ||
|
||
assert response.status_code == 200 |