def test_subscribe(self): channel1 = Channel('heartbeat', ['BTC-USD', 'LTC-USD']) channel2 = Channel('level2', ['LTC-USD']) channel3 = Channel('heartbeat', ['BTC-USD', 'BTC-EUR']) channel4 = Channel('heartbeat', ['ETH-USD']) client = Client(self.loop, [channel1], auto_connect=False) self.assertIn(channel1.name, client.channels) self.assertEqual(client.channels[channel1.name], channel1) client.subscribe(channel2) self.assertIn(channel2.name, client.channels) self.assertEqual(client.channels[channel2.name], channel2) client.subscribe(channel3) self.assertIn(channel3.name, client.channels) self.assertEqual(client.channels[channel3.name], channel1 + channel3) client.protocol.sendMessage = MagicMock() client.connected.set() client.subscribe(channel4) msg = client._get_subscribe_message([channel4]) client.protocol.sendMessage.assert_called_with(msg)
def test__as_dict(self): channel = Channel('heartbeat', ['BTC-USD', 'LTC-USD']) d = channel._as_dict() self.assertIsInstance(d, dict) self.assertEqual(d['name'], 'heartbeat') self.assertEqual(len(d['product_ids']), 2) self.assertIn('BTC-USD', d['product_ids']) self.assertIn('LTC-USD', d['product_ids'])
def test___eq__(self): channel1 = Channel('heartbeat', ['BTC-USD', 'LTC-USD']) channel2 = Channel('heartbeat', ['BTC-USD', 'LTC-USD']) channel3 = Channel('heartbeat', 'BTC-USD') channel4 = Channel('heartbeat', ['BTC-USD']) channel5 = Channel('ticker', ['BTC-USD']) self.assertEqual(channel1, channel2) self.assertEqual(channel3, channel4) self.assertNotEqual(channel1, channel3) with self.assertRaises(TypeError): comp = (channel4 == channel5)
def main(): settings = input_args() loop = asyncio.get_event_loop() channel = Channel('level2', settings.currency_pair) channel2 = Channel('ticker', settings.currency_pair) ws = crobat.recorder.L2_Update(loop, channel, settings) ws.subscribe(channel2) try: loop.run_forever() except KeyboardInterrupt: loop.run_until_complete(ws.close()) loop.close()
def test_unsubscribe(self): channel1 = Channel('heartbeat', ['BTC-USD', 'LTC-USD', 'LTC-EUR']) channel2 = Channel('level2', ['LTC-USD']) channel3 = Channel('heartbeat', ['LTC-EUR']) channel4 = Channel('heartbeat', ['BTC-USD', 'BTC-EUR']) channel5 = Channel('heartbeat', ['BCH-USD', 'LTC-USD']) client = Client(self.loop, [channel1, channel2], auto_connect=False) client.unsubscribe(channel3) self.assertIn(channel3.name, client.channels) self.assertEqual(client.channels[channel3.name], Channel('heartbeat', ['BTC-USD', 'LTC-USD'])) client.unsubscribe(channel4) self.assertIn(channel4.name, client.channels) self.assertEqual(client.channels[channel4.name], Channel('heartbeat', ['LTC-USD'])) client.unsubscribe(channel3) self.assertIn(channel3.name, client.channels) self.assertEqual(client.channels[channel3.name], Channel('heartbeat', ['LTC-USD'])) client.unsubscribe(channel2) self.assertNotIn(channel2.name, client.channels) client.unsubscribe(channel5) self.assertEqual(client.channels, {})
def test___sub__(self): channel1 = Channel('heartbeat', ['BTC-USD', 'LTC-USD']) channel2 = Channel('heartbeat', ['BTC-USD', 'LTC-USD']) channel3 = Channel('heartbeat', ['LTC-USD']) channel4 = Channel('ticker', ['LTC-USD']) self.assertIsNone(channel1 - channel2) channel = channel1 - channel3 self.assertEqual(channel.name, 'heartbeat') self.assertEqual(channel.product_ids, {'BTC-USD'}) with self.assertRaises(TypeError): channel = channel1 - channel4
def main(): settings = rec.input_args(recording_duration=2) loop = asyncio.get_event_loop() channel = Channel('level2', settings.currency_pair) channel2 = Channel('ticker', settings.currency_pair) ws = rec.L2_Update(loop, channel, settings) ws.subscribe(channel2) count = 0 timestart = datetime.utcnow() try: loop.run_forever() except KeyboardInterrupt: loop.run_until_complete(ws.close()) loop.close()
def test_on_open(self): channel1 = Channel('heartbeat', ['BTC-USD', 'LTC-USD', 'LTC-EUR']) channel2 = Channel('level2', ['LTC-USD']) client = Client(self.loop, [channel1, channel2], auto_connect=False) client.protocol.sendMessage = MagicMock() self.assertFalse(client.connected.is_set()) self.assertTrue(client.disconnected.is_set()) self.assertFalse(client.closing) msg = client._get_subscribe_message(client.channels.values()) client.on_open() self.assertTrue(client.connected.is_set()) self.assertFalse(client.disconnected.is_set()) self.assertFalse(client.closing) client.protocol.sendMessage.assert_called_with(msg)
def main(): if args.currency_pair: print("The currency_pair selected is {}.".format(args.currency_pair)) else: args.currency_pair = "ETH-USD" print("The default currency_pair, ETH-USD, will be used.") if args.recording_duration: print("This session will record for {} seconds".format(args.recording_duration)) else: print("The default session length of 5 seconds will be used") args.recording_duration = 5 if args.position_range: print("The position_range is set to {} positions from the best bid/ask".format(args.position_range)) else: print("The default position range of 5 will be used.") args.position_range = 5 if args.sides: args.sides = args.sides.replace(" ", "") args.sides = args.sides.split(",") print("The sides selected are: {}".format(args.sides)) else: print("The default sides are ['bid', 'ask', 'signed']") args.sides = ['bid', 'ask', 'signed'] if args.filetype: args.filetype = args.filetype.replace(" ", "") args.filetype = args.filetype.split(",") print("The output filetypes selected are {}".format(args.filetype)) else: print("no files will be printed") args.filetype = ['csv'] #if args. settings_1 = input_args(currency_pair=args.currency_pair, position_range=args.position_range, recording_duration=args.recording_duration, sides=args.sides, filetype=args.filetype) loop = asyncio.get_event_loop() channel1 = Channel('level2', settings_1.currency_pair) #channel2 = Channel('ticker', settings_1.currency_pair) ws_1 = rec.L2_Update(loop, channel1, settings_1) #ws_1.subscribe(channel2) #count = 0 timestart=datetime.utcnow() try: loop.run_forever() except KeyboardInterrupt: loop.run_until_complete(ws_1.close()) #loop.run_until_complete(ws_2.close()) loop.close()
def test__init__(self): #no channel name, no product_ids with self.assertRaises(TypeError): channel = Channel() #channel name, no product_ids: with self.assertRaises(TypeError): channel = Channel('heartbeat') #valid name channel = Channel('heartbeat', 'BTC-USD') self.assertEqual(channel.name, 'heartbeat') #invalid name with self.assertRaises(ValueError): channel = Channel('pulse', 'BTC-USD') #lower case channel = Channel('TiCKeR', 'BTC-USD') self.assertEqual(channel.name, 'ticker') #product_ids as str channel = Channel('heartbeat', 'BTC-USD') self.assertIsInstance(channel.product_ids, set) self.assertEqual(channel.product_ids, set(['BTC-USD'])) #product_ids as list length 1 channel = Channel('heartbeat', ['BTC-USD']) self.assertIsInstance(channel.product_ids, set) self.assertEqual(channel.product_ids, set(['BTC-USD'])) #product_ids as list length 2 channel = Channel('heartbeat', ['BTC-USD', 'LTC-USD']) self.assertIsInstance(channel.product_ids, set) self.assertEqual(channel.product_ids, set(['BTC-USD', 'LTC-USD'])) #empty product_ids string with self.assertRaises(ValueError): channel = Channel('heartbeat', '') #empty product_ids list with self.assertRaises(ValueError): channel = Channel('heartbeat', [])
def connect_ws(): loop = asyncio.get_event_loop() channel = Channel('ticker', 'BTC-USD') ws = Ticker(loop, channel) try: loop.run_forever() except KeyboardInterrupt: loop.run_until_complete(ws.close()) loop.close()
def test_subscribe(self): channel1 = Channel('heartbeat', ['BTC-USD', 'LTC-USD']) channel2 = Channel('level2', ['LTC-USD']) channel3 = Channel('heartbeat', ['BTC-USD', 'BTC-EUR']) client = Client(self.loop, [channel1], auto_connect=False) self.assertIn(channel1.name, client.channels) self.assertEqual(client.channels[channel1.name], channel1) client.subscribe(channel2) self.assertIn(channel2.name, client.channels) self.assertEqual(client.channels[channel2.name], channel2) client.subscribe(channel3) self.assertIn(channel3.name, client.channels) self.assertEqual(client.channels[channel3.name], channel1 + channel3)
async def test_close(self): channel1 = Channel('heartbeat', ['BTC-USD', 'LTC-USD', 'LTC-EUR']) client = Client(self.loop, [channel1], auto_connect=False) client.protocol.sendClose = MagicMock( side_effect=lambda: client.disconnected.set()) client.disconnected.clear() self.assertFalse(client.closing) await client.close() self.assertTrue(client.closing) client.protocol.sendClose.assert_called_once()
def coinbase(): loop = asyncio.get_event_loop() ws = Coinbase( loop, Channel('ticker', ['BTC-USD', 'ETH-USD', 'LTC-USD', 'ETC-USD', 'BCH-USD']), **config) try: loop.run_forever() except KeyboardInterrupt: loop.run_until_complete(ws.close()) loop.close()
def test__get_subscribe_message(self): channel1 = Channel('heartbeat', ['BTC-USD', 'LTC-USD']) channel2 = Channel('level2', ['LTC-USD']) client = Client(self.loop, [channel1, channel2], auto_connect=False) #subscribe msg = json.loads( client._get_subscribe_message( client.channels.values()).decode('utf8')) self.assertEqual(len(msg), 2) self.assertEqual(msg['type'], 'subscribe') self.assertIn(channel1._as_dict(), msg['channels']) self.assertIn(channel2._as_dict(), msg['channels']) #unsubscribe msg = json.loads( client._get_subscribe_message([channel1], unsubscribe=True).decode('utf8')) self.assertEqual(len(msg), 2) self.assertEqual(msg['type'], 'unsubscribe') self.assertIn(channel1._as_dict(), msg['channels']) self.assertFalse(channel2._as_dict() in msg['channels']) #authorized client = Client(self.loop, channel1, auth=True, key=TEST_KEY, secret=TEST_SECRET, passphrase=TEST_PASSPHRASE, auto_connect=False, auto_reconnect=False) msg = json.loads( client._get_subscribe_message( client.channels.values(), timestamp='1546384260.0321212').decode('utf8')) self.assertEqual(len(msg), 6) self.assertEqual(msg['type'], 'subscribe') self.assertIn(channel1._as_dict(), msg['channels']) self.assertEqual(msg['key'], TEST_KEY) self.assertEqual(msg['passphrase'], TEST_PASSPHRASE) self.assertEqual(msg['timestamp'], '1546384260.0321212') self.assertEqual(msg['signature'], 'KQq/poDCHjDDRURkQOc+QZi16c6cio9Yo/nF1+kts84=')
def test_on_close(self): channel1 = Channel('heartbeat', ['BTC-USD', 'LTC-USD', 'LTC-EUR']) client = Client(self.loop, [channel1], auto_connect=False) client.add_as_task_to_loop = MagicMock() client.connected.set() client.disconnected.clear() client.closing = True client.on_close(True, None, None) self.assertFalse(client.connected.is_set()) self.assertTrue(client.disconnected.is_set()) self.assertTrue(client.closing) client.add_as_task_to_loop.assert_not_called()
def test___add__(self): channel1 = Channel('heartbeat', ['BTC-USD', 'LTC-USD']) channel2 = Channel('heartbeat', ['BTC-EUR', 'LTC-EUR']) channel3 = Channel('heartbeat', 'BTC-USD') channel4 = Channel('ticker', ['BTC-EUR', 'LTC-EUR']) channel = channel1 + channel2 self.assertEqual(channel.name, 'heartbeat') self.assertEqual(channel.product_ids, {'BTC-USD', 'LTC-USD', 'BTC-EUR', 'LTC-EUR'}) channel = channel1 + channel3 self.assertEqual(channel.name, "heartbeat") self.assertEqual(channel.product_ids, {'BTC-USD', 'LTC-USD'}) channel1 += channel2 self.assertEqual(channel1.name, 'heartbeat') self.assertEqual(channel1.product_ids, {'BTC-USD', 'LTC-USD', 'BTC-EUR', 'LTC-EUR'}) with self.assertRaises(TypeError): channel = channel1 + channel4
def test_add_as_task_to_loop(self): channel1 = Channel('heartbeat', ['BTC-USD', 'LTC-USD']) client = Client(self.loop, channel1, auto_connect=False) client.loop.create_connection = CoroutineMock( return_value=CoroutineMock()) client.add_as_task_to_loop() url = urlparse(FEED_URL) client.loop.create_connection.assert_called_with(client, url.hostname, url.port, ssl=True)
def test__get_subscribe_message(self): channel1 = Channel('heartbeat', ['BTC-USD', 'LTC-USD']) channel2 = Channel('level2', ['LTC-USD']) client = Client(self.loop, [channel1, channel2], auto_connect=False) msg = json.loads( client._get_subscribe_message( client.channels.values()).decode('utf8')) self.assertIn('type', msg) self.assertEqual(msg['type'], 'subscribe') self.assertIn('channels', msg) self.assertIn(channel1._as_dict(), msg['channels']) self.assertIn(channel2._as_dict(), msg['channels'])
def test__init__auto_connect(self): channel1 = Channel('heartbeat', ['BTC-USD', 'LTC-USD']) #noauth, auto_connect, name with patch('copra.websocket.client.Client.add_as_task_to_loop' ) as mock_attl: client = Client(self.loop, channel1, name="Custom Name") self.assertEqual(client.loop, self.loop) self.assertEqual(client._initial_channels, [channel1]) self.assertEqual(client.feed_url, FEED_URL) self.assertEqual(client.channels, {channel1.name: channel1}) self.assertFalse(client.auth) self.assertTrue(client.auto_connect) self.assertTrue(client.auto_reconnect) self.assertEqual(client.name, 'Custom Name') self.assertFalse(client.connected.is_set()) self.assertTrue(client.disconnected.is_set()) self.assertFalse(client.closing) mock_attl.assert_called_once()
def main(): currency_pair = input("Please state your currency pair:") recording_duration = input("Please state your recording_duration:") position_range = input("Please state your position range:") sides = input("Please state your sides separted by ',':") filetype = input("Please state desired output filetypes separted by ',':") recording_duration = float(recording_duration) position_range = int(position_range) sides.replace(" ", "") sides = sides.split(",") filetype.replace(" ", "") filetype = filetype.split(",") #print(currency_pair, recording_duration, position_range, sides, filetype) settings_1 = input_args(currency_pair=currency_pair, position_range=position_range, recording_duration=recording_duration, sides=sides, filetype=filetype) loop = asyncio.get_event_loop() channel1 = Channel('level2', settings_1.currency_pair) #channel2 = Channel('ticker', settings_1.currency_pair) ws_1 = rec.L2_Update(loop, channel1, settings_1) #ws_1.subscribe(channel2) #count = 0 timestart=datetime.utcnow() try: loop.run_forever() except KeyboardInterrupt: loop.run_until_complete(ws_1.close()) #loop.run_until_complete(ws_2.close()) loop.close()
def test_unsubscribe(self): channel1 = Channel('heartbeat', ['BTC-USD', 'LTC-USD', 'LTC-EUR']) channel2 = Channel('level2', ['LTC-USD']) channel3 = Channel('heartbeat', ['LTC-EUR']) channel4 = Channel('heartbeat', ['BTC-USD', 'BTC-EUR']) channel5 = Channel('heartbeat', ['BCH-USD', 'LTC-USD']) client = Client(self.loop, [channel1, channel2], auto_connect=False) client.unsubscribe(channel3) self.assertIn(channel3.name, client.channels) self.assertEqual(client.channels[channel3.name], Channel('heartbeat', ['BTC-USD', 'LTC-USD'])) client.unsubscribe(channel4) self.assertIn(channel4.name, client.channels) self.assertEqual(client.channels[channel4.name], Channel('heartbeat', ['LTC-USD'])) client.unsubscribe(channel3) self.assertIn(channel3.name, client.channels) self.assertEqual(client.channels[channel3.name], Channel('heartbeat', ['LTC-USD'])) client.unsubscribe(channel2) self.assertNotIn(channel2.name, client.channels) client.protocol.sendMessage = MagicMock() client.connected.set() client.unsubscribe(channel5) self.assertEqual(client.channels, {}) msg = client._get_subscribe_message([channel5], unsubscribe=True) client.protocol.sendMessage.assert_called_with(msg)
def main(): settings_1 = input_args(recording_duration=60) loop = asyncio.get_event_loop() channel1 = Channel('ticker', settings_1.currency_pair) #channel2 = Channel('ticker', settings_1.currency_pair) ws_1 = jsc.Ticker(loop, channel1, settings_1) #ws_1.subscribe(channel2) #count = 0 timestart = datetime.utcnow() try: loop.run_forever() except KeyboardInterrupt: loop.run_until_complete(ws_1.close()) #loop.run_until_complete(ws_2.close()) loop.close()
# self.size = float(tick_dict['last_size']) # self.time = datetime.strptime(tick_dict['time'], '%Y-%m-%dT%H:%M:%S.%fZ') # @property # def spread(self): # return self.best_ask - self.best_bid # def __repr__(self): # rep = "{}\t\t\t\t{}\n".format(self.product_id, self.time) # rep += "=============================================================\n" # rep += " Price: ${:.2f}\tSize:{:.8f}\tSide:{: >5}\n".format(self.price, self.size, self.side) # rep += "Best ask: ${:.2f}\tBest bid: ${:.2f}\tSpread: ${:.2f}\n".format(self.best_ask, self.best_bid, self.spread) # rep += "=============================================================\n" # return rep class Match(Client): def on_message(self, message): for f in message: print(f, " : ", message[f]) print("=============================================================\n") product_id = sys.argv[1] loop = asyncio.get_event_loop() channel = Channel('heartbeat', product_id) matcher = Match(loop, channel) try: loop.run_forever() except KeyboardInterrupt: loop.run_until_complete(matcher.close()) loop.close()
import asyncio import pandas as pd import json from copra.websocket import Channel, Client from autobahn.asyncio.websocket import WebSocketClientFactory loop = asyncio.get_event_loop() global dataFeed class MyClient(Client): def on_message(self, message): dataFeed = pd.DataFrame(message, index=[len(message)]) print(dataFeed.iloc[0]) # ws = MyClient(loop, Channel('heartbeat', 'BTC-USD')) ws1 = MyClient(loop, Channel('ticker', 'BTC-USD')) try: loop.run_forever() except KeyboardInterrupt: # loop.run_until_complete(ws.close()) loop.run_until_complete(ws1.close()) loop.close()
import asyncio from copra.websocket import Channel, Client from autobahn.asyncio.websocket import WebSocketClientFactory class Client(WebSocketClientFactory): def on_message(self, message): tick = Tick(message) print(tick, "\n\n") # if message['type'] == 'ticker' and 'time' in message: loop = asyncio.get_event_loop() ws = Client(loop, Channel('full', 'BTC-USD')) ticker = Ticker(loop, ws) try: loop.run_forever() except KeyboardInterrupt: loop.run_until_complete(ws.close()) loop.close()
# Insert Values into SQL Server cursor.execute( f"""INSERT INTO [dbo].[{table_name}] (price, bid, ask, side, time, size, trade_id) VALUES {insert_tuple}""") cnxn.commit() if log_inserts: print(insert_tuple) except Exception: print(f"""SQL Insert failed for ({float(message['price'])}, {float(message['best_bid'])}, {float(message['best_ask'])}, {message['side']}, {message['time']}, {float(message['last_size'])}, {int(message['trade_id'])}) """) print("General Error message working on refinement") # An outer catch needs to replace this for debugging purposes loop = asyncio.get_event_loop() channel = Channel('ticker', product_id) ticker = Ticker(loop, channel) try: loop.run_forever() except KeyboardInterrupt: loop.run_until_complete(ticker.close()) loop.close()
def test__init__(self): channel1 = Channel('heartbeat', ['BTC-USD', 'LTC-USD']) channel2 = Channel('level2', ['LTC-USD']) client = Client(self.loop, channel1, auto_connect=False) self.assertEqual(client._initial_channels, [channel1]) self.assertEqual(client.feed_url, 'wss://ws-feed.pro.coinbase.com:443') client = Client(self.loop, channel1, SANDBOX_FEED_URL, auto_connect=False) self.assertEqual(client.feed_url, SANDBOX_FEED_URL) client = Client(self.loop, channel1, auto_connect=False) self.assertEqual(client._initial_channels, [channel1]) self.assertEqual(client.channels, {channel1.name: channel1}) client = Client(self.loop, [channel1], auto_connect=False) self.assertEqual(client._initial_channels, [channel1]) self.assertEqual(client.channels, {channel1.name: channel1}) client = Client(self.loop, [channel1, channel2], auto_connect=False) self.assertEqual(client._initial_channels, [channel1, channel2]) self.assertEqual(client.channels, { channel1.name: channel1, channel2.name: channel2 }) client = Client(self.loop, [channel1, channel2], name="Test", auto_connect=False) self.assertEqual(client.name, "Test") #auth, no key, secret, or passphrase with self.assertRaises(ValueError): client = Client(self.loop, channel1, auth=True, auto_connect=False) #auth, key, no secret or passphrase with self.assertRaises(ValueError): client = Client(self.loop, channel1, auth=True, key='MyKey', auto_connect=False) #auth, key, secret, no passphrase with self.assertRaises(ValueError): client = Client(self.loop, channel1, auth=True, key='MyKey', secret='MySecret', auto_connect=False) #auth, secret, no key or passphrase with self.assertRaises(ValueError): client = Client(self.loop, channel1, auth=True, secret='MySecret', auto_connect=False) #auth, secret, passphrase, no key with self.assertRaises(ValueError): client = Client(self.loop, channel1, auth=True, secret='MySecret', passphrase='MyPassphrase', auto_connect=False) #auth, passphrase, no key or secret with self.assertRaises(ValueError): client = Client(self.loop, channel1, auth=True, passphrase='MyPassphrase', auto_connect=False) #auth, key, secret, passphrase client = Client(self.loop, channel1, auth=True, key='MyKey', secret='MySecret', passphrase='MyPassphrase', auto_connect=False) self.assertTrue(client.auth) self.assertEqual(client.key, 'MyKey') self.assertEqual(client.secret, 'MySecret') self.assertEqual(client.passphrase, 'MyPassphrase')
if price > bestbid and price < bestask: fakevol = fakevol + qty print('\033[93m', '-- EXECUTION BETWEEN SPREAD (_o_): ', price, 'for', qty, '\033[0m') else: legitvol = legitvol + qty print('\u001b[38;5;244m', '-- Legit Trade: ', price, 'for', qty, '\033[0m') print('\033[95m', 'total fake: ', fakevol, ' BTC', '\033[0m') print('\033[95m', 'total legit: ', legitvol, ' BTC', '\033[0m') #match = Match(message) #print(tick, "\n\n") product_id = "BTC-USD" loop = asyncio.get_event_loop() channelt = Channel('level2', product_id) channelm = Channel('matches', product_id) ticker = Ticker(loop, channelt) ticker = Ticker(loop, channelm) try: loop.run_forever() except KeyboardInterrupt: loop.run_until_complete(ticker.close()) loop.close()
def test__init__(self): channel1 = Channel('heartbeat', ['BTC-USD', 'LTC-USD']) channel2 = Channel('level2', ['LTC-USD']) client = Client(self.loop, channel1, auto_connect=False) self.assertEqual(client._initial_channels, [channel1]) self.assertEqual(client.feed_url, 'wss://ws-feed.pro.coinbase.com:443') client = Client(self.loop, channel1, SANDBOX_FEED_URL, auto_connect=False) self.assertEqual(client.feed_url, SANDBOX_FEED_URL) client = Client(self.loop, channel1, auto_connect=False) self.assertEqual(client._initial_channels, [channel1]) self.assertEqual(client.channels, {channel1.name: channel1}) client = Client(self.loop, [channel1], auto_connect=False) self.assertEqual(client._initial_channels, [channel1]) self.assertEqual(client.channels, {channel1.name: channel1}) client = Client(self.loop, [channel1, channel2], auto_connect=False) self.assertEqual(client._initial_channels, [channel1, channel2]) self.assertEqual(client.channels, { channel1.name: channel1, channel2.name: channel2 }) client = Client(self.loop, [channel1, channel2], name="Test", auto_connect=False) self.assertEqual(client.name, "Test") #auth, no key, secret, or passphrase with self.assertRaises(ValueError): client = Client(self.loop, channel1, auth=True, auto_connect=False) #auth, key, no secret or passphrase with self.assertRaises(ValueError): client = Client(self.loop, channel1, auth=True, key='MyKey', auto_connect=False) #auth, key, secret, no passphrase with self.assertRaises(ValueError): client = Client(self.loop, channel1, auth=True, key='MyKey', secret='MySecret', auto_connect=False) #auth, secret, no key or passphrase with self.assertRaises(ValueError): client = Client(self.loop, channel1, auth=True, secret='MySecret', auto_connect=False) #auth, secret, passphrase, no key with self.assertRaises(ValueError): client = Client(self.loop, channel1, auth=True, secret='MySecret', passphrase='MyPassphrase', auto_connect=False) #auth, passphrase, no key or secret with self.assertRaises(ValueError): client = Client(self.loop, channel1, auth=True, passphrase='MyPassphrase', auto_connect=False) #auth, key, secret, passphrase client = Client(self.loop, channel1, auth=True, key=TEST_KEY, secret=TEST_SECRET, passphrase=TEST_PASSPHRASE, auto_connect=False, auto_reconnect=False) self.assertEqual(client.loop, self.loop) self.assertEqual(client._initial_channels, [channel1]) self.assertEqual(client.feed_url, FEED_URL) self.assertEqual(client.channels, {channel1.name: channel1}) self.assertTrue(client.auth) self.assertEqual(client.key, TEST_KEY) self.assertEqual(client.secret, TEST_SECRET) self.assertEqual(client.passphrase, TEST_PASSPHRASE) self.assertFalse(client.auto_connect) self.assertFalse(client.auto_reconnect) self.assertEqual(client.name, 'WebSocket Client') self.assertFalse(client.connected.is_set()) self.assertTrue(client.disconnected.is_set()) self.assertFalse(client.closing)