Skip to content

Commit

Permalink
Rename WebSocketMessageHandler to WebSocketMessagesHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
nkiryanov committed Jun 8, 2024
1 parent 32646f7 commit 47d86c4
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/handlers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from handlers.message_handler import WebSocketMessageHandler
from handlers.messages_handler import WebSocketMessagesHandler

__all__ = [
"WebSocketMessageHandler",
"WebSocketMessagesHandler",
]
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


@dataclass
class WebSocketMessageHandler:
class WebSocketMessagesHandler:
storage: SubscriptionStorage

def __post_init__(self) -> None:
Expand Down
4 changes: 2 additions & 2 deletions src/handlers/tests/message_handler/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from handlers import WebSocketMessageHandler
from handlers import WebSocketMessagesHandler
from handlers.dto import AuthMessage, SubscribeMessage, UnsubscribeMessage


Expand All @@ -18,7 +18,7 @@ def force_token_on_validation(mocker, valid_token):

@pytest.fixture
def message_handler(storage):
return WebSocketMessageHandler(storage=storage)
return WebSocketMessagesHandler(storage=storage)


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from app.types import DecodedValidToken
from handlers.dto import SuccessResponseMessage
from handlers.exceptions import WebsocketMessageException
from handlers import WebSocketMessageHandler
from handlers import WebSocketMessagesHandler
from storage.storage_updaters import StorageWebSocketRegister

pytestmark = [
Expand All @@ -18,7 +18,7 @@ def ya_user_decoded_valid_token():


@pytest.fixture
def auth_handler(message_handler: WebSocketMessageHandler, ws):
def auth_handler(message_handler: WebSocketMessagesHandler, ws):
return lambda auth_message: message_handler.handle_auth_message(ws, auth_message)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import pytest
from handlers.message_handler import WebSocketMessageHandler
from handlers.messages_handler import WebSocketMessagesHandler


@pytest.fixture
def get_message_handler(storage):
return lambda: WebSocketMessageHandler(storage)
return lambda: WebSocketMessagesHandler(storage)


def test_message_handler_jwk_client_settings(message_handler):
Expand All @@ -14,23 +14,23 @@ def test_message_handler_jwk_client_settings(message_handler):

@pytest.mark.usefixtures("force_token_on_validation")
async def test_message_handler_call_auth_handler_on_auth_message(get_message_handler, auth_message, mocker, ws):
spy_auth_handler = mocker.spy(WebSocketMessageHandler, "handle_auth_message")
spy_auth_handler = mocker.spy(WebSocketMessagesHandler, "handle_auth_message")

await get_message_handler().handle_message(ws, auth_message)

spy_auth_handler.assert_awaited_once()


async def test_message_handler_call_subscribe_handler_on_subscribe_message(get_message_handler, subscribe_message, mocker, ws_registered):
spy_subscribe_handler = mocker.spy(WebSocketMessageHandler, "handle_subscribe_message")
spy_subscribe_handler = mocker.spy(WebSocketMessagesHandler, "handle_subscribe_message")

await get_message_handler().handle_message(ws_registered, subscribe_message)

spy_subscribe_handler.assert_awaited_once()


async def test_message_handler_call_unsubscribe_handler_on_unsubscribe_message(get_message_handler, unsubscribe_message, mocker, ws_subscribed):
spy_unsubscribe_handler = mocker.spy(WebSocketMessageHandler, "handle_unsubscribe_message")
spy_unsubscribe_handler = mocker.spy(WebSocketMessagesHandler, "handle_unsubscribe_message")

await get_message_handler().handle_message(ws_subscribed, unsubscribe_message)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import pytest
from handlers.message_handler import WebSocketMessageHandler
from handlers.messages_handler import WebSocketMessagesHandler
from storage.storage_updaters import StorageUserSubscriber


@pytest.fixture
def subscribe_handler(message_handler: WebSocketMessageHandler, ws_registered):
def subscribe_handler(message_handler: WebSocketMessagesHandler, ws_registered):
return lambda subscribe_message: message_handler.handle_subscribe_message(ws_registered, subscribe_message)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import pytest
from handlers.message_handler import WebSocketMessageHandler
from handlers.messages_handler import WebSocketMessagesHandler
from storage.storage_updaters import StorageUserUnsubscriber


@pytest.fixture
def unsubscribe_handler(message_handler: WebSocketMessageHandler, ws_subscribed):
def unsubscribe_handler(message_handler: WebSocketMessagesHandler, ws_subscribed):
return lambda unsubscribe_message: message_handler.handle_unsubscribe_message(ws_subscribed, unsubscribe_message)


Expand Down

0 comments on commit 47d86c4

Please sign in to comment.