def mock_batch(self, requests, response_timeout=None, make_async=False): mapping = { 'test-request-single-arg': TEST_RPC_ONE_PARAMETER, 'test-notify-single-arg': TEST_RPC_ONE_PARAMETER_NO_RETURN, 'set-camera': TEST_RPC_ONEOF_PARAMETER, 'set-camera-no-return': TEST_RPC_ONEOF_PARAMETER_NO_RETURN, 'set-mode': TEST_RPC_ONEOF_PARAMETER_WEIRD_CASING, 'inspect': TEST_RPC_ARRAY_PARAMETER, 'inspect-notify': TEST_RPC_ARRAY_PARAMETER_NO_RETURN, 'test-rpc-invalid-type': TEST_RPC_INVALID_TYPE, 'test-rpc-no-type': TEST_RPC_NO_TYPE, 'test-rpc-two-params': TEST_RPC_TWO_PARAMETERS, 'test-rpc-return': TEST_RPC_ONLY_RETURN, 'test-notification': TEST_RPC_NOTIFICATION, 'test-object': TEST_OBJECT_SCHEMA, 'test-array': TEST_ARRAY_SCHEMA, 'add-model': TEST_ADD_MODEL, 'version': VERSION_SCHEMA } if make_async: import copy mapping = copy.deepcopy(mapping) for i in mapping.values(): if 'async' in i: i['async'] = True results = list() for request in requests: schema = request.params['endpoint'] request_id = request.request_id() if schema in mapping: results.append(rockets.Response(result=mapping[schema], _id=request_id)) else: results.append(rockets.Response(error={'code': -42, 'message': 'Invalid stuff'}, _id=request_id)) return results
def mock_batch_request_invalid_rpc_param(self, requests, response_timeout=None, make_async=False): results = list() for request in requests: schema = request.params['endpoint'] request_id = request.request_id() if schema == 'test-rpc-invalid-param': results.append(rockets.Response(result=TEST_RPC_INVALID_PARAM, _id=request_id)) return results