Skip to content

Commit

Permalink
removed import not used
Browse files Browse the repository at this point in the history
  • Loading branch information
fdelcampo authored and sebastian-aranda committed Jan 5, 2022
1 parent e8db12c commit acc7d54
Showing 1 changed file with 31 additions and 23 deletions.
54 changes: 31 additions & 23 deletions manager/subscription/tests/test_subscriptions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Tests for the subscription of consumers to streams."""
import asyncio
import pytest
import os

from django.contrib.auth.models import User, Permission
from channels.testing import WebsocketCommunicator
from manager.routing import application
Expand Down Expand Up @@ -391,38 +391,39 @@ async def test_request_initial_state_when_subscribing_to_event(self):
await client_communicator.connect()
await producer_communicator.connect()

# Act 1 (Subscribe producer)
await producer_communicator.send_json_to(
{
"option": "subscribe",
"category": "initial_state",
"csc": "all",
"salindex": "all",
"stream": "all",
}
# initial state is only useful for events
combinations = filter(
lambda item: (item["category"] == "event"), self.combinations
)
await producer_communicator.receive_json_from()

# Act 2 (Subscribe client)
for combination in self.combinations:
# initial state is only useful for events
if combination["category"] != "event":
continue
for combination in combinations:
# Act 1 (Subscribe producer)
await producer_communicator.send_json_to(
{
"option": "subscribe",
"category": "initial_state",
"csc": combination["csc"],
"salindex": "all",
"stream": "all",
}
)
producer_response = await producer_communicator.receive_json_from()
expected = {
"data": "Successfully subscribed to initial_state-"
+ combination["csc"]
+ "-all-all"
}
assert producer_response == expected

# Act 2 (Subscribe client)
msg = {
"option": "subscribe",
"csc": combination["csc"],
"salindex": combination["salindex"],
"stream": combination["stream"],
"category": combination["category"],
}

# Subscribe the first time
await client_communicator.send_json_to(msg)
producer_consumer_response = await producer_communicator.receive_json_from()

# Assert first subscription
assert producer_consumer_response == {
expected = {
"category": "initial_state",
"data": [
{
Expand All @@ -434,5 +435,12 @@ async def test_request_initial_state_when_subscribing_to_event(self):
"subscription": "initial_state-all-all-all",
}

# Subscribe the first time
await client_communicator.send_json_to(msg)
producer_consumer_response = await producer_communicator.receive_json_from()

# Assert first subscription
assert producer_consumer_response == expected

await client_communicator.disconnect()
await producer_communicator.disconnect()

0 comments on commit acc7d54

Please sign in to comment.