Skip to content

Commit

Permalink
Merge pull request #31 from lsst-ts/release/1.0.0
Browse files Browse the repository at this point in the history
Release/1.0.0
  • Loading branch information
spereirag authored Sep 11, 2019
2 parents bc5329c + 38daf7d commit cfb98a6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
19 changes: 13 additions & 6 deletions manager/subscription/consumers.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ async def handle_data_message(self, message):
'category': category,
'csc': csc,
'salindex': salindex,
'data': {stream: data_csc[stream]}
'data': {stream: data_csc[stream]},
'subscription': group_name
}
)
streams_data[stream] = data_csc[stream]
Expand All @@ -180,7 +181,8 @@ async def handle_data_message(self, message):
'category': category,
'csc': csc,
'salindex': salindex,
'data': {csc: streams_data}
'data': {csc: streams_data},
'subscription': '-'.join([category, csc, str(salindex), 'all'])
}
)

Expand Down Expand Up @@ -254,15 +256,17 @@ async def subscription_data(self, message):
category = message['category']
salindex = message['salindex']
csc = message['csc']
subscription = message['subscription']

# Send data to WebSocket
await self.send(text_data=json.dumps({
'category': category,
'data': [{
'csc': csc,
'salindex': salindex,
'data': data,
}]
'data': data
}],
'subscription': subscription
}))

async def subscription_ack(self, message):
Expand Down Expand Up @@ -292,7 +296,8 @@ async def subscription_ack(self, message):
'csc': csc,
'salindex': salindex,
'data': data,
}]
}],
'subscription': 'cmd_acks-all-all-all'
}))

async def subscription_all_data(self, message):
Expand All @@ -308,9 +313,11 @@ async def subscription_all_data(self, message):
"""
data = message['data']
category = message['category']
# subscription = '{}-all-all-all'.format(category)

# Send data to WebSocket
await self.send(text_data=json.dumps({
'category': category,
'data': data
'data': data,
'subscription': '{}-all-all-all'.format(category)
}))
12 changes: 9 additions & 3 deletions manager/subscription/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def build_messages(self, category, csc, salindex, streams):
'csc': csc,
'salindex': salindex,
'data': {stream: {'value': 1.02813957817852497, 'dataType': 'Float'} for stream in streams}
}]
}],
'subscription': '{}-{}-{}-{}'.format(category, csc, salindex, streams[0])
}
return response, response

Expand Down Expand Up @@ -149,7 +150,8 @@ async def test_authorized_user_gets_ack(self):
"cmd_id": 12345
}
}
}]
}],
"subscription": "cmd_acks-all-all-all"
}
ack = {
"category": "ack",
Expand All @@ -163,12 +165,16 @@ async def test_authorized_user_gets_ack(self):
"cmd_id": 12345
}
}
}]
}],
"subscription": "cmd_acks-all-all-all"
}
await communicator.send_json_to(msg_send)
await communicator.receive_json_from()
await communicator.send_json_to(msg_receive)
# Assert
response = await communicator.receive_json_from()
print(ack)
print('\n\n\n')
print(response)
assert ack == response
await communicator.disconnect()
6 changes: 5 additions & 1 deletion manager/subscription/tests/test_subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ def build_messages(self, category, csc, salindex, streams):
'csc': csc,
'salindex': salindex,
'data': {stream: {'value': 1.02813957817852497, 'dataType': 'Float'} for stream in streams}
}]
}],
'subscription': '{}-{}-{}-{}'.format(category, csc, salindex, streams[0])
}
return response, response

Expand Down Expand Up @@ -194,8 +195,11 @@ async def test_receive_messages_from_all_subscription(self):
self.build_messages(combination['category'], combination['csc'], combination['salindex'], [
combination['stream']])
await communicator.send_json_to(msg)
expected['subscription'] = '{}-all-all-all'.format(combination['category'])
response = await communicator.receive_json_from()
# Assert
print(response)
print(expected)
assert response == expected
await communicator.disconnect()

Expand Down

0 comments on commit cfb98a6

Please sign in to comment.