Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_unmute(self):
client = WebOSClient("ws://a")
media = MediaControl(client)
media.mute(False)
self.assert_sent_message_without_id({
"type": "request",
"uri": "ssap://audio/setMute",
"payload": {"mute": False}
})
def set_volume(self):
client = WebOSClient("ws://a")
media = MediaControl(client)
media.set_volume(30)
self.assert_sent_message_without_id({
"type": "request",
"uri": "ssap://audio/setVolume",
"payload": {"volume": 30}
})
def test_mute(self):
client = WebOSClient("ws://a")
media = MediaControl(client)
media.mute(True)
self.assert_sent_message_without_id({
"type": "request",
"uri": "ssap://audio/setMute",
"payload": {"mute": True}
})
}))
return send_response
def patched_send_message(*args, **kwargs):
kwargs["unique_id"] = "1"
obj = WebOSClient.send_message(client, *args, **kwargs)
sent_event.set()
return obj
client.send_message = patched_send_message
store = {}
Thread(target=make_response(True, True, False)).start()
gen = client.register(store, timeout=10)
assert next(gen) == WebOSClient.PROMPTED
assert next(gen) == WebOSClient.REGISTERED
assert store == {"client_key": "xyz"}
# Test with non-empty store.
Thread(target=make_response(False, True, False)).start()
assert list(client.register(store, timeout=10)) ==\
[WebOSClient.REGISTERED]
assert "xyz" in json.dumps(client.sent_message)
# Test wrong response.
Thread(target=make_response(False, False, True)).start()
with raises(Exception):
list(client.register(store, timeout=10))
def test_volume_down(self):
client = WebOSClient("ws://a")
media = MediaControl(client)
media.volume_down()
self.assert_sent_message_without_id({
"type": "request",
"uri": "ssap://audio/volumeDown"
})
def test_mute(self):
client = WebOSClient("ws://a")
media = MediaControl(client)
media.mute(True)
self.assert_sent_message_without_id({
"type": "request",
"uri": "ssap://audio/setMute",
"payload": {"mute": True}
})
def test_volume_down(self):
client = WebOSClient("ws://a")
media = MediaControl(client)
media.volume_down()
self.assert_sent_message_without_id({
"type": "request",
"uri": "ssap://audio/volumeDown"
})
def set_volume(self):
client = WebOSClient("ws://a")
media = MediaControl(client)
media.set_volume(30)
self.assert_sent_message_without_id({
"type": "request",
"uri": "ssap://audio/setVolume",
"payload": {"volume": 30}
})
def test_unmute(self):
client = WebOSClient("ws://a")
media = MediaControl(client)
media.mute(False)
self.assert_sent_message_without_id({
"type": "request",
"uri": "ssap://audio/setMute",
"payload": {"mute": False}
})
def test_volume_up(self):
client = WebOSClient("ws://a")
media = MediaControl(client)
media.volume_up()
self.assert_sent_message_without_id({
"type": "request",
"uri": "ssap://audio/volumeUp"
})