def test_list(self): history = History() history_event = HistoryEvent() history.events.append(history_event) thrift_object = copy_py_to_thrift(history) self.assertIsInstance(thrift_object, cadence_thrift.shared.History) self.assertEqual(1, len(thrift_object.events))
def test_copy_with_enum(self): event: HistoryEvent = HistoryEvent() event.event_type = EventType.ActivityTaskFailed thrift_object = copy_py_to_thrift(event) self.assertIsInstance(thrift_object, cadence_thrift.shared.HistoryEvent) self.assertEqual(EventType.ActivityTaskFailed, thrift_object.eventType) self.assertIsInstance(thrift_object.eventType, int) self.assertEqual(int(EventType.ActivityTaskFailed), thrift_object.eventType)
def thrift_call(self, method_name, request_argument): thrift_request_argument = copy_py_to_thrift(request_argument) fn = getattr(cadence_thrift.WorkflowService, method_name, None) assert fn request = fn.request(thrift_request_argument) request_payload = cadence_thrift.dumps(request) call = ThriftFunctionCall.create(TCHANNEL_SERVICE, "WorkflowService::" + method_name, request_payload) response = self.connection.call_function(call) start_response = cadence_thrift.loads(fn.response, response.thrift_payload) return start_response
def test_copy(self): thrift_object = copy_py_to_thrift(self.python_object) self.assertIsInstance(thrift_object, cadence_thrift.shared.PollForActivityTaskResponse) self.assertEqual("TASK_TOKEN", thrift_object.taskToken) self.assertEqual("WORKFLOW_ID", thrift_object.workflowExecution.workflowId) self.assertEqual("RUN_ID", thrift_object.workflowExecution.runId)
def test_dict(self): register_domain = RegisterDomainRequest() register_domain.data["name"] = "test" thrift_object = copy_py_to_thrift(register_domain) self.assertIsInstance(thrift_object, cadence_thrift.shared.RegisterDomainRequest) self.assertEqual("test", thrift_object.data["name"])
def test_list_primitive(self): retry_policy = RetryPolicy() retry_policy.non_retriable_error_reasons.append("abc") thrift_object = copy_py_to_thrift(retry_policy) self.assertIsInstance(thrift_object, cadence_thrift.shared.RetryPolicy) self.assertIn("abc", thrift_object.nonRetriableErrorReasons)