Ejemplo n.º 1
0
    def test_release_bounty_to_public_is_successful():
        now = timezone.now()
        profile = Profile(
            handle='foo',
        )
        bounty = Bounty(
            title='ReleaseToPublicTrueTest',
            idx_status='reserved',
            is_open=True,
            web3_created=now,
            expires_date=now + timezone.timedelta(minutes=2),
            bounty_reserved_for_user=profile,
            reserved_for_user_from=now,
            reserved_for_user_expiration=now + timezone.timedelta(minutes=2),
            github_url='https://github.com/gitcoinco/web/issues/12345678',
            raw_data={}
        )

        assert bounty.bounty_reserved_for_user is not None
        assert bounty.reserved_for_user_from is not None
        assert bounty.reserved_for_user_expiration is not None

        assert release_bounty_to_the_public(bounty, False) is True

        assert bounty.bounty_reserved_for_user is None
        assert bounty.reserved_for_user_from is None
        assert bounty.reserved_for_user_expiration is None
Ejemplo n.º 2
0
    def test_total_reserved_length_label_empty_when_bounty_not_reserved():
        bounty = Bounty(
            title='ReservedLengthLabelTest',
            idx_status=0,
            is_open=True,
            web3_created=datetime(2008, 10, 31, tzinfo=pytz.UTC),
            expires_date=datetime(2008, 11, 30, tzinfo=pytz.UTC),
            github_url='https://github.com/gitcoinco/web/issues/12345678',
            raw_data={})

        assert bounty.total_reserved_length_label == ''
Ejemplo n.º 3
0
 def test_bounty_snooze_url():
     """Test the dashboard Bounty model snooze_url method."""
     bounty = Bounty(
         title='foo',
         value_in_token=3,
         token_name='ETH',
         web3_created=datetime(2008, 10, 31, tzinfo=pytz.UTC),
         github_url='https://github.com/gitcoinco/web/issues/12',
         token_address='0x0',
         issue_description='hello world',
         bounty_owner_github_username='******',
         is_open=False,
         accepted=False,
         expires_date=datetime(2008, 11, 30, tzinfo=pytz.UTC),
         idx_project_length=5,
         project_length='Months',
         bounty_type='Feature',
         experience_level='Intermediate',
         raw_data={},
     )
     assert bounty.snooze_url(1) == f'{bounty.get_absolute_url()}?snooze=1'
Ejemplo n.º 4
0
    def test_total_reserved_length_label_is_indefinite_when_no_expiration_set(
    ):
        dummy_profile = Profile(handle='foo')

        bounty = Bounty(
            title='ReservedLengthLabelTest',
            idx_status=0,
            is_open=True,
            web3_created=datetime(2008, 10, 31, tzinfo=pytz.UTC),
            expires_date=datetime(2008, 11, 30, tzinfo=pytz.UTC),
            github_url='https://github.com/gitcoinco/web/issues/12345678',
            bounty_reserved_for_user=dummy_profile,
            reserved_for_user_from=timezone.now(),
            raw_data={})

        assert bounty.total_reserved_length_label == 'indefinitely'
Ejemplo n.º 5
0
    def test_total_reserved_length_label_when_reservation_is_three_hours():
        dummy_profile = Profile(handle='foo')

        now = timezone.now()
        bounty = Bounty(
            title='ReservedLengthLabelTest',
            idx_status=0,
            is_open=True,
            web3_created=datetime(2008, 10, 31, tzinfo=pytz.UTC),
            expires_date=datetime(2008, 11, 30, tzinfo=pytz.UTC),
            github_url='https://github.com/gitcoinco/web/issues/12345678',
            bounty_reserved_for_user=dummy_profile,
            reserved_for_user_from=now,
            reserved_for_user_expiration=now + timezone.timedelta(hours=3),
            raw_data={})

        assert bounty.total_reserved_length_label == '3 hours'
Ejemplo n.º 6
0
 def test_bounty_expired():
     """Test the status and details of an expired bounty."""
     bounty = Bounty(
         title='foo',
         value_in_token=3,
         token_name='ETH',
         web3_created=datetime(2008, 10, 31, tzinfo=pytz.UTC),
         github_url='https://github.com/gitcoinco/web/issues/12',
         token_address='0x0',
         issue_description='hello world',
         bounty_owner_github_username='******',
         is_open=False,
         accepted=False,
         expires_date=datetime(2008, 11, 30, tzinfo=pytz.UTC),
         idx_project_length=5,
         project_length='Months',
         bounty_type='Feature',
         experience_level='Intermediate',
         raw_data={},
     )
     assert bounty.status == 'expired'
Ejemplo n.º 7
0
 def test_bounty(self):
     """Test the dashboard Bounty model."""
     bounty = Bounty(
         title='foo',
         value_in_token=3,
         token_name='ETH',
         web3_created=datetime(2008, 10, 31),
         github_url='https://github.com/gitcoinco/web',
         token_address='0x0',
         issue_description='hello world',
         fulfiller_github_username='******',
         bounty_owner_github_username='******',
         is_open=False,
         accepted=True,
         expires_date=datetime(2008, 11, 30),
         fulfiller_address="0x0000000000000000000000000000000000000000",
         idx_project_length=5,
         bounty_type='Feature',
         experience_level='Intermediate',
     )
     assert str(bounty) == 'foo 3 ETH 2008-10-31 00:00:00'
     assert bounty.url == '/funding/details?url=https://github.com/gitcoinco/web'
     assert bounty.title_or_desc == 'foo'
     assert bounty.issue_description_text == 'hello world'
     assert bounty.org_name == 'gitcoinco'
     assert bounty.is_hunter('fred') is True
     assert bounty.is_hunter('flintstone') is False
     assert bounty.is_funder('fred') is False
     assert bounty.is_funder('flintstone') is True
     assert bounty.get_avatar_url
     assert bounty.status == 'expired'
     assert bounty.value_true == 3e-18
     assert bounty.value_in_eth == 3
     assert bounty.value_in_usdt == 0
     assert 'ago 5 Feature Intermediate' in bounty.desc
     assert bounty.is_legacy is False
     assert bounty.get_github_api_url(
     ) == 'https://api.github.com/repos/gitcoinco/web'