def __init__(
     self,
     crypto_com_auth: Optional[CryptoComAuth] = None,
     shared_client: Optional[aiohttp.ClientSession] = None,
 ):
     self._crypto_com_auth: CryptoComAuth = crypto_com_auth
     self._shared_client = shared_client or aiohttp.ClientSession()
     super().__init__(data_source=CryptoComAPIUserStreamDataSource(
         crypto_com_auth=self._crypto_com_auth,
         shared_client=self._shared_client))
Exemple #2
0
 def data_source(self) -> UserStreamTrackerDataSource:
     """
     *required
     Initializes a user stream data source (user specific order diffs from live socket stream)
     :return: OrderBookTrackerDataSource
     """
     if not self._data_source:
         self._data_source = CryptoComAPIUserStreamDataSource(
             crypto_com_auth=self._crypto_com_auth,
             shared_client=self._shared_client)
     return self._data_source
    def setUp(self) -> None:
        super().setUp()

        self.log_records = []
        self.async_task: Optional[asyncio.Task] = None

        self.data_source = CryptoComAPIUserStreamDataSource(crypto_com_auth=self.auth)

        self.data_source.logger().setLevel(1)
        self.data_source.logger().addHandler(self)

        self.mocking_assistant = NetworkMockingAssistant()
        self.resume_test_event = asyncio.Event()
 def test_get_shared_client_shared_client_provided(self):
     aiohttp_client = aiohttp.ClientSession()
     data_source = CryptoComAPIUserStreamDataSource(crypto_com_auth=self.auth, shared_client=aiohttp_client)
     self.assertEqual(data_source._get_shared_client(), aiohttp_client)