Skip to content

Commit

Permalink
fix unit tests: test_subscribe_handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricardo Cañuelo committed Dec 1, 2023
1 parent 832dcc2 commit b0c6cb0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions tests/unit_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
)
from api.models import UserGroup
from api.user_models import User
from api.pubsub import PubSub
from api.pubsub import PubSub, Subscription

BEARER_TOKEN = "Bearer \
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJib2IifQ.\
Expand Down Expand Up @@ -223,8 +223,10 @@ def mock_pubsub_subscriptions(mocker):
"""Mocks `_redis` and `_subscriptions` member of PubSub class instance"""
pubsub = PubSub()
redis_mock = fakeredis.aioredis.FakeRedis()
sub = Subscription(id=1, channel='test')
mocker.patch.object(pubsub, '_redis', redis_mock)
subscriptions_mock = dict({1: pubsub._redis.pubsub()})
subscriptions_mock = dict(
{1: {'sub': sub, 'redis_sub': pubsub._redis.pubsub()}})
mocker.patch.object(pubsub, '_subscriptions', subscriptions_mock)
return pubsub

Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/test_subscribe_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ def test_subscribe_endpoint(mock_subscribe, test_client):
)
print("response.json()", response.json())
assert response.status_code == 200
assert ('id', 'channel') == tuple(response.json().keys())
assert ('id', 'channel', 'user') == tuple(response.json().keys())

0 comments on commit b0c6cb0

Please sign in to comment.