示例#1
0
    def test_go_failed(self, requests):
        requests.get.return_value = DummyResponse('', 404)

        rest = Spell({
            'endpoint': self.ENDPOINT
        })

        results = rest.go()

        for item in results:
            assert not item

        requests.get.assert_called_once_with(self.ENDPOINT, headers=rest.get_headers())
示例#2
0
文件: oauth.py 项目: ye11ow/tohsaka
    def get_headers(self):
        headers = BaseRest.get_headers(self)

        headers['X-Access-Token'] = self.config.get('token')
        headers['X-Client-ID'] = self.config.get('client_id')

        return headers
示例#3
0
文件: fund.py 项目: ye11ow/tohsaka
 def go(self):
     for item in BaseSpell.go(self):
         data = item['data'][0]
         net = float(data['net'])
         yield {
             'name': data['name'],
             'unit_value': net,
             'date': data['enddate'],
             'total_value': net * float(self.config['units'])
         }
示例#4
0
文件: fund.py 项目: ye11ow/tohsaka
 def __init__(self, config):
     code = config['code']
     print(config)
     config[
         'endpoint'] = f'https://fund.10jqka.com.cn/data/client/myfund/{code}'
     BaseSpell.__init__(self, config)
示例#5
0
文件: oauth.py 项目: ye11ow/tohsaka
 def __init__(self, config):
     BaseRest.__init__(self, config)
示例#6
0
    def test_intro(self):
        name = Spell.intro()

        assert type(name) == str
        assert len(name) > 0
示例#7
0
    def test_name(self):
        name = Spell.name()

        assert type(name) == str
        assert len(name) > 0