def test_get(self):
     responses.add(responses.GET, 'https://gitcoin.co/api/v0.1/bounties/123', json={'mock': 'mock'}, status=200)
     api = Gitcoin()
     result = api.bounties.get(123)
     assert result == {'mock': 'mock'}
     assert len(responses.calls) == 1
     responses.calls[0].request.url == 'https://gitcoin.co/api/v0.1/bounties/123'
 def test_filter_pk__gt(self):
     responses.add(responses.GET, 'https://gitcoin.co/api/v0.1/bounties/', json={'mock': 'mock'}, status=200)
     api = Gitcoin()
     result = api.bounties.filter(pk__gt=100).all()
     assert result == {'mock': 'mock'}
     assert len(responses.calls) == 1
     assert are_url_queries_equal(responses.calls[0].request.url, 'https://gitcoin.co/api/v0.1/bounties/?pk__gt=100')
 def test_filter_2x_bounty_type_paged(self):
     responses.add(responses.GET, 'https://gitcoin.co/api/v0.1/bounties/', json={'mock': 'mock'}, status=200)
     api = Gitcoin()
     result = api.bounties.filter(bounty_type='Feature').filter(bounty_type='Bug').get_page()
     assert result == {'mock': 'mock'}
     assert len(responses.calls) == 1
     assert are_url_queries_equal(
         responses.calls[0].request.url,
         'https://gitcoin.co/api/v0.1/bounties/?bounty_type=Feature%2CBug&offset=0&limit=25'
     )
 def test_filter_bounty_type(self):
     responses.add(responses.GET, 'https://gitcoin.co/api/v0.1/bounties/', json={'mock': 'mock'}, status=200)
     api = Gitcoin()
     result = api.bounties.filter(bounty_type='Bug').all()
     assert result == {'mock': 'mock'}
     assert len(responses.calls) == 1
     assert are_url_queries_equal(
         responses.calls[0].request.url, 'https://gitcoin.co/api/v0.1/bounties/?bounty_type=Bug'
     )
     with pytest.raises(ValueError):
         api.bounties.filter(bounty_type='Fancy')
 def test_filter_project_length(self):
     responses.add(responses.GET, 'https://gitcoin.co/api/v0.1/bounties/', json={'mock': 'mock'}, status=200)
     api = Gitcoin()
     result = api.bounties.filter(project_length='Hours').all()
     assert result == {'mock': 'mock'}
     assert len(responses.calls) == 1
     assert are_url_queries_equal(
         responses.calls[0].request.url, 'https://gitcoin.co/api/v0.1/bounties/?project_length=Hours'
     )
     with pytest.raises(ValueError):
         api.bounties.filter(project_length='Minutes')
 def test_filter_experience_level(self):
     responses.add(responses.GET, 'https://gitcoin.co/api/v0.1/bounties/', json={'mock': 'mock'}, status=200)
     api = Gitcoin()
     result = api.bounties.filter(experience_level='Beginner').all()
     assert result == {'mock': 'mock'}
     assert len(responses.calls) == 1
     assert are_url_queries_equal(
         responses.calls[0].request.url, 'https://gitcoin.co/api/v0.1/bounties/?experience_level=Beginner'
     )
     with pytest.raises(ValueError):
         api.bounties.filter(experience_level='Rockstar')
    def test_no_normalize(self):

        class ExtendedBountyConfig(BountyConfig):

            def __init__(self):
                super().__init__()
                self.params['no_normalize'] = (True, None)

        api = Gitcoin()
        api.set_class('bounties_list_config', ExtendedBountyConfig)

        responses.add(responses.GET, 'https://gitcoin.co/api/v0.1/bounties/', json={'mock': 'mock'}, status=200)

        result = api.bounties.filter(no_normalize='not_normal').get_page()
        assert result == {'mock': 'mock'}
        assert len(responses.calls) == 1
        assert are_url_queries_equal(
            responses.calls[0].request.url,
            'https://gitcoin.co/api/v0.1/bounties/?no_normalize=not_normal&offset=0&limit=25'
        )
 def test_filter_idx_status(self):
     responses.add(responses.GET, 'https://gitcoin.co/api/v0.1/bounties/', json={'mock': 'mock'}, status=200)
     api = Gitcoin()
     result = api.bounties.filter(idx_status='started').all()
     assert result == {'mock': 'mock'}
     assert len(responses.calls) == 1
     assert are_url_queries_equal(
         responses.calls[0].request.url, 'https://gitcoin.co/api/v0.1/bounties/?idx_status=started'
     )
     with pytest.raises(ValueError):
         api.bounties.filter(idx_status='undone')
    def test_order_by(self):
        responses.add(responses.GET, 'https://gitcoin.co/api/v0.1/bounties/', json={'mock': 'mock'}, status=200)
        api = Gitcoin()

        result = api.bounties.order_by('-project_length').get_page()
        assert result == {'mock': 'mock'}
        assert len(responses.calls) == 1
        assert are_url_queries_equal(
            responses.calls[0].request.url,
            'https://gitcoin.co/api/v0.1/bounties/?order_by=-project_length&offset=0&limit=25'
        )

        result = api.bounties.order_by('is_open').get_page()
        assert result == {'mock': 'mock'}
        assert len(responses.calls) == 2
        assert are_url_queries_equal(
            responses.calls[1].request.url,
            'https://gitcoin.co/api/v0.1/bounties/?order_by=is_open&offset=0&limit=25'
        )

        with pytest.raises(ValueError):
            api.bounties.order_by('random')
 def test_api_raises_on_unknown_param(self):
     api = Gitcoin()
     with pytest.raises(KeyError):
         api.bounties.filter(does_not_exist=True)
 def test_raise_for_status(self):
     responses.add(responses.GET, 'https://gitcoin.co/api/v0.1/bounties/', json={'mock': 'mock'}, status=401)
     api = Gitcoin()
     with pytest.raises(requests.exceptions.HTTPError):
         result = api.bounties.all()
Beispiel #12
0
from datetime import datetime
from threading import Timer
from credentials import TOKEN
from gitcoin import Gitcoin
import telebot
import requests
import json

bot = telebot.TeleBot(TOKEN)
api = Gitcoin()

try:
    with open('users.json') as f:
        users = json.load(f)
except:
    users = []


@bot.message_handler(commands=['start', 'help'])
def start(message):  # add user to list fo users waiting a issue
    bot.send_message(
        message.from_user.id,
        text=
        'I will send to you all new issues in gitcoin site, you just need to send me a /getNewIssues, and you can cancel it anytime sending me a /cancelSubscription'
    )


def add_user(user):
    if user in users:
        return
    users.append(user)