def test_instantiates_with_payload(self): response = MethodResponse(request_id=dummy_rid, status=dummy_status, payload=dummy_payload) assert response.payload == dummy_payload new_payload = {"NewPayload": "yes_this_is_new"} assert response.payload != new_payload response.payload = new_payload assert response.payload == new_payload
def test_instantiates_with_status(self): response = MethodResponse(request_id=dummy_rid, status=dummy_status, payload=dummy_payload) assert response.status == dummy_status new_status = 400 assert response.status != new_status response.status = new_status assert response.status == new_status
def test_instantiates_with_request_id(self): response = MethodResponse(request_id=dummy_rid, status=dummy_status, payload=dummy_payload) assert response.request_id == dummy_rid new_rid = "2" assert response.request_id != new_rid response.request_id = new_rid assert response.request_id == new_rid
def test_send_method_response_calls_transport(self, client, transport): response = MethodResponse(request_id="1", status=200, payload={"key": "value"}) client.send_method_response(response) assert transport.send_method_response.call_count == 1 assert transport.send_method_response.call_args[0][0] is response
def test_instantiates_without_payload(self): request = MethodRequest(request_id=dummy_rid, name=dummy_name, payload=dummy_payload) status = 200 response = MethodResponse.create_from_method_request(request, status) assert isinstance(response, MethodResponse) assert response.request_id == request.request_id assert response.status == status assert response.payload is None
def test_instantiates_from_method_request(self): request = MethodRequest(request_id=dummy_rid, name=dummy_name, payload=dummy_payload) status = 200 payload = {"ResponsePayload": "SomeResponse"} response = MethodResponse.create_from_method_request( method_request=request, status=status, payload=payload) assert isinstance(response, MethodResponse) assert response.request_id == request.request_id assert response.status == status assert response.payload == payload
def method_response(): return MethodResponse(request_id="1", status=200, payload={"key": "value"})
def test_instantiates_without_payload(self): response = MethodResponse(request_id=dummy_rid, status=dummy_status) assert response.request_id == dummy_rid assert response.status == dummy_status assert response.payload is None