Skip to content

Commit a53ce1e

Browse files
committed
chore: fix unit tests
1 parent 3787ba1 commit a53ce1e

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

juju/client/connection.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import websockets
1818
from dateutil.parser import parse
1919
from typing_extensions import Self, TypeAlias, overload
20-
from websockets.protocol import State
2120

2221
from juju import errors, jasyncio, tag, utils
2322
from juju.client import client
@@ -93,7 +92,7 @@ def status(self):
9392
and connection._receiver_task.cancelled()
9493
)
9594

96-
if stopped or connection._ws.state is not State.OPEN:
95+
if stopped or connection._ws.state is not websockets.protocol.State.OPEN:
9796
return self.ERROR
9897

9998
# everything is fine!

tests/unit/test_connection.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from unittest import mock
88

99
import pytest
10+
import websockets
1011
from websockets.exceptions import ConnectionClosed
1112

1213
from juju.client.connection import Connection
@@ -17,8 +18,7 @@ class WebsocketMock:
1718
def __init__(self, responses):
1819
super().__init__()
1920
self.responses = deque(responses)
20-
self.open = True
21-
self.closed = False
21+
self.state = websockets.protocol.State.OPEN
2222

2323
async def send(self, message):
2424
pass
@@ -30,8 +30,7 @@ async def recv(self):
3030
return json.dumps(self.responses.popleft())
3131

3232
async def close(self):
33-
self.open = False
34-
self.closed = True
33+
pass
3534

3635

3736
async def test_out_of_order():

0 commit comments

Comments
 (0)