forked from LBRYCommunity/lbry-sdk
minor error class and type checking fixes
This commit is contained in:
parent
73613d1583
commit
c25d72d911
3 changed files with 9 additions and 4 deletions
|
@ -72,7 +72,7 @@ class AioHttpManager:
|
|||
async def get_response_body(self):
|
||||
response = await asyncio.wait_for(self._make_request(), self.REQUESTS_TIMEOUT)
|
||||
if self.content_type not in response.headers.get('Content-Type'):
|
||||
raise InvalidExchangeRateResponse(self.url, f'Received response is not of type {self.content_type}')
|
||||
raise InvalidExchangeRateResponseError(self.url, f'Received response is not of type {self.content_type}')
|
||||
return response.read().decode()
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import os
|
||||
import json
|
||||
import typing
|
||||
import logging
|
||||
from binascii import unhexlify
|
||||
from typing import Optional, List
|
||||
|
@ -15,13 +16,16 @@ from lbry.wallet.account import Account
|
|||
from lbry.wallet.ledger import MainNetLedger
|
||||
from lbry.wallet.transaction import Transaction, Output
|
||||
from lbry.wallet.database import WalletDatabase
|
||||
from lbry.extras.daemon.exchange_rate_manager import ExchangeRateManager
|
||||
from lbry.conf import Config
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from lbry.extras.daemon.exchange_rate_manager import ExchangeRateManager
|
||||
|
||||
|
||||
class LbryWalletManager(BaseWalletManager):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
@ -195,7 +199,8 @@ class LbryWalletManager(BaseWalletManager):
|
|||
return tx
|
||||
|
||||
async def create_purchase_transaction(
|
||||
self, accounts: List[Account], txo: Output, exchange: ExchangeRateManager, override_max_key_fee=False):
|
||||
self, accounts: List[Account], txo: Output, exchange: 'ExchangeRateManager',
|
||||
override_max_key_fee=False):
|
||||
fee = txo.claim.stream.fee
|
||||
fee_amount = exchange.to_dewies(fee.currency, fee.amount)
|
||||
if not override_max_key_fee and self.config.max_key_fee:
|
||||
|
|
|
@ -310,5 +310,5 @@ class TestAioHttpManager(AsyncioTestCase):
|
|||
manager = exchange_rate_manager.AioHttpManager('some url', 'some params', 'json')
|
||||
with unittest.mock.patch.object(
|
||||
exchange_rate_manager.AioHttpManager, '_make_request', make_request_mock
|
||||
), self.assertRaises(InvalidExchangeRateResponse):
|
||||
), self.assertRaises(InvalidExchangeRateResponseError):
|
||||
await manager.get_response_body()
|
||||
|
|
Loading…
Reference in a new issue