def test_create_api_message_special(): """Create a API message response of a request with non defaults.""" request = get_new_request('Alexa.PowerController', 'TurnOn') directive_header = request['directive']['header'] directive_header.pop('correlationToken') directive = messages.AlexaDirective(request) msg = directive.response('testName', 'testNameSpace')._response assert 'event' in msg msg = msg['event'] assert msg['header']['messageId'] is not None assert msg['header']['messageId'] != directive_header['messageId'] assert 'correlationToken' not in msg['header'] assert msg['header']['name'] == 'testName' assert msg['header']['namespace'] == 'testNameSpace' assert msg['header']['payloadVersion'] == '3' assert msg['payload'] == {} assert 'endpoint' not in msg
def test_create_api_message_special(): """Create a API message response of a request with non defaults.""" request = get_new_request("Alexa.PowerController", "TurnOn") directive_header = request["directive"]["header"] directive_header.pop("correlationToken") directive = messages.AlexaDirective(request) msg = directive.response("testName", "testNameSpace")._response assert "event" in msg msg = msg["event"] assert msg["header"]["messageId"] is not None assert msg["header"]["messageId"] != directive_header["messageId"] assert "correlationToken" not in msg["header"] assert msg["header"]["name"] == "testName" assert msg["header"]["namespace"] == "testNameSpace" assert msg["header"]["payloadVersion"] == "3" assert msg["payload"] == {} assert "endpoint" not in msg
def test_create_api_message_defaults(hass): """Create a API message response of a request with defaults.""" request = get_new_request('Alexa.PowerController', 'TurnOn', 'switch#xy') directive_header = request['directive']['header'] directive = messages.AlexaDirective(request) msg = directive.response(payload={'test': 3})._response assert 'event' in msg msg = msg['event'] assert msg['header']['messageId'] is not None assert msg['header']['messageId'] != directive_header['messageId'] assert msg['header']['correlationToken'] == \ directive_header['correlationToken'] assert msg['header']['name'] == 'Response' assert msg['header']['namespace'] == 'Alexa' assert msg['header']['payloadVersion'] == '3' assert 'test' in msg['payload'] assert msg['payload']['test'] == 3 assert msg['endpoint'] == request['directive']['endpoint'] assert msg['endpoint'] is not request['directive']['endpoint']
def test_create_api_message_defaults(hass): """Create a API message response of a request with defaults.""" request = get_new_request("Alexa.PowerController", "TurnOn", "switch#xy") directive_header = request["directive"]["header"] directive = messages.AlexaDirective(request) msg = directive.response(payload={"test": 3})._response assert "event" in msg msg = msg["event"] assert msg["header"]["messageId"] is not None assert msg["header"]["messageId"] != directive_header["messageId"] assert msg["header"]["correlationToken"] == directive_header[ "correlationToken"] assert msg["header"]["name"] == "Response" assert msg["header"]["namespace"] == "Alexa" assert msg["header"]["payloadVersion"] == "3" assert "test" in msg["payload"] assert msg["payload"]["test"] == 3 assert msg["endpoint"] == request["directive"]["endpoint"] assert msg["endpoint"] is not request["directive"]["endpoint"]