Пример #1
0
async def test_request_with_ctx(token, session, tracking_id, headers):
    async with AsyncClient(token, session=session) as client:
        result = await client._request('GET', '/path', Empty, params={'k': 1})

    assert result.tracking_id == tracking_id
    session.request.assert_called_once_with(
        'GET',
        f'{PRODUCTION}/path',
        headers=headers,
        params={'k': 1},
        raise_for_status=False,
    )
    session.close.assert_called_once_with()
Пример #2
0
async def test_default_session(token):
    client = AsyncClient(token)

    assert isinstance(client._session, aiohttp.ClientSession)
Пример #3
0
async def test_request_unexpected_error(token, session):
    client = AsyncClient(token, session=session)

    with pytest.raises(UnexpectedError):
        await client._request('GET', '/path', Empty)
Пример #4
0
async def test_request_bad_request(token, session):
    client = AsyncClient(token, session=session)

    with pytest.raises(BadRequestError):
        await client._request('GET', '/path', Empty)
Пример #5
0
 async def get_market_orderbook(self, figi, depth):
     async with AsyncClient(self.TOKEN) as client:
         return await client.get_market_orderbook(figi, depth)
Пример #6
0
async def test_request_too_many_requests(token, session):
    client = AsyncClient(token, session=session)

    with pytest.raises(TooManyRequestsError):
        await client._request('GET', '/path', Empty)
Пример #7
0
 async def get_market_candles(self, figi, from_, to, interval):
     async with AsyncClient(self.TOKEN) as client:
         return await client.get_market_candles(figi, from_, to, interval)
Пример #8
0
 async def get_market_etfs(self):
     async with AsyncClient(self.TOKEN) as client:
         return await client.get_market_etfs()
Пример #9
0
 async def get_market_search_by_figi(self, figi):
     async with AsyncClient(self.TOKEN) as client:
         response = await client.get_market_search_by_figi(figi)
     return {figi: response.payload}
Пример #10
0
 async def get_market_stocks(self):
     async with AsyncClient(self.TOKEN) as client:
         response = await client.get_market_stocks()
     return response
Пример #11
0
 async def get_market_currencies(self):
     async with AsyncClient(self.TOKEN) as client:
         result = await client.get_market_currencies()
         result = result.payload.json()
     return json.loads(result)['instruments']
Пример #12
0
 async def get_accounts(self):
     async with AsyncClient(self.TOKEN) as client:
         return await client.get_accounts()
Пример #13
0
 async def get_portfolio_currencies(self):
     async with AsyncClient(self.TOKEN) as client:
         result = await client.get_portfolio_currencies()
         result = result.payload.json()
     return json.loads(result)['currencies']
Пример #14
0
 async def get_operations(self, from_, to):
     async with AsyncClient(self.TOKEN) as client:
         response = await client.get_operations(from_, to)
     return response.payload
Пример #15
0
 async def get_portfolio(self):
     async with AsyncClient(self.TOKEN) as client:
         response = await client.get_portfolio()
     return response.payload.json()