Skip to content

Commit

Permalink
chore: fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaqq committed Nov 27, 2024
1 parent 3787ba1 commit a53ce1e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
3 changes: 1 addition & 2 deletions juju/client/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import websockets
from dateutil.parser import parse
from typing_extensions import Self, TypeAlias, overload
from websockets.protocol import State

from juju import errors, jasyncio, tag, utils
from juju.client import client
Expand Down Expand Up @@ -93,7 +92,7 @@ def status(self):
and connection._receiver_task.cancelled()
)

if stopped or connection._ws.state is not State.OPEN:
if stopped or connection._ws.state is not websockets.protocol.State.OPEN:
return self.ERROR

# everything is fine!
Expand Down
7 changes: 3 additions & 4 deletions tests/unit/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from unittest import mock

import pytest
import websockets
from websockets.exceptions import ConnectionClosed

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

async def send(self, message):
pass
Expand All @@ -30,8 +30,7 @@ async def recv(self):
return json.dumps(self.responses.popleft())

async def close(self):
self.open = False
self.closed = True
pass


async def test_out_of_order():
Expand Down

0 comments on commit a53ce1e

Please sign in to comment.