33import traceback
44import pytest
55import pytest_mock
6- import rx
6+ import reactivex
7+ from websockets .frames import Close
78
89import deriv_api
910from deriv_api .errors import APIError , ConstructionError , ResponseError
1011from deriv_api .easy_future import EasyFuture
11- from rx .subject import Subject
12- import rx .operators as op
12+ from reactivex .subject import Subject
13+ import reactivex .operators as op
1314import pickle
1415import json
1516from websockets .exceptions import ConnectionClosedOK , ConnectionClosedError
@@ -362,7 +363,7 @@ async def test_ws_disconnect():
362363 class MockedWs2 (MockedWs ):
363364 def __init__ (self ):
364365 self .closed = EasyFuture ()
365- self .exception = ConnectionClosedOK (1000 , 'test disconnect' )
366+ self .exception = ConnectionClosedOK (Close ( 1000 , 'test disconnect' ), None , None )
366367 super ().__init__ ()
367368 async def close (self ):
368369 self .closed .resolve (self .exception )
@@ -376,7 +377,7 @@ async def recv(self):
376377
377378 # closed by api
378379 wsconnection = MockedWs2 ()
379- wsconnection .exception = ConnectionClosedOK (1000 , 'Closed by api' )
380+ wsconnection .exception = ConnectionClosedOK (Close ( 1000 , 'Closed by api' ), None , None )
380381 api = deriv_api .DerivAPI (connection = wsconnection )
381382 await asyncio .sleep (0.1 )
382383 api .wsconnection_from_inside = True
@@ -399,7 +400,7 @@ async def recv(self):
399400 # closed by remote
400401 wsconnection = MockedWs2 ()
401402 api = deriv_api .DerivAPI (connection = wsconnection )
402- wsconnection .exception = ConnectionClosedError (1234 , 'Closed by remote' )
403+ wsconnection .exception = ConnectionClosedError (Close ( 1234 , 'Closed by remote' ), None , None )
403404 last_error = api .sanity_errors .pipe (op .first (), op .to_future ())
404405 await asyncio .sleep (0.1 ) # waiting for init finished
405406 await wsconnection .close () # it will set connected as 'Closed by disconnect', and cause MockedWs2 raising `test disconnect`
0 commit comments