Skip to content

Commit 4b8e686

Browse files
committed
Change 'authenticated' to 'authorized' in stream2
1 parent c592afe commit 4b8e686

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

alpaca_trade_api/stream2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ async def _connect(self):
3131
r = r.decode('utf-8')
3232
msg = json.loads(r)
3333

34-
if 'data' not in msg or msg['data']['status'] != 'authorized':
34+
if not 'data' in msg or msg['data']['status'] != 'authorized':
3535
raise ValueError(
3636
("Invalid Alpaca API credentials, Failed to authenticate: {}"
3737
.format(msg))
3838
)
3939

4040
self._ws = ws
41-
await self._dispatch('authenticated', msg)
41+
await self._dispatch('authorized', msg)
4242

4343
asyncio.ensure_future(self._consume_msg())
4444
return ws

tests/test_stream2.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,21 @@ def test_stream(websockets):
3838
ws.recv = AsyncMock(return_value=json.dumps({
3939
'stream': 'authentication',
4040
'data': {
41-
'status': 'authenticated',
41+
'status': 'authorized',
4242
}
4343
}).encode())
4444

4545
conn = StreamConn('key-id', 'secret-key')
4646
conn._consume_msg = AsyncMock()
4747

48-
@conn.on('authenticated')
48+
@conn.on('authorized')
4949
async def on_auth(conn, stream, msg):
5050
on_auth.msg = msg
5151
_run(conn._connect())
52-
assert on_auth.msg.status == 'authenticated'
52+
assert on_auth.msg.status == 'authorized'
5353
assert conn._consume_msg.mock.called
5454

55-
conn.deregister('authenticated')
55+
conn.deregister('authorized')
5656
assert len(conn._handlers) == 0
5757

5858
with pytest.raises(ValueError):

0 commit comments

Comments
 (0)