Skip to content

Commit

Permalink
fix wf type conflict in test
Browse files Browse the repository at this point in the history
  • Loading branch information
longquanzheng committed Sep 12, 2023
1 parent 06834e6 commit 5d16708
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions iwf/tests/test_signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def execute(
return StateDecision.graceful_complete_workflow(sig3.value)


class WaitWorkflow(ObjectWorkflow):
class WaitSignalWorkflow(ObjectWorkflow):
def get_communication_schema(self) -> CommunicationSchema:
return CommunicationSchema.create(
CommunicationMethod.signal_channel_def(test_channel_int, int),
Expand All @@ -78,13 +78,13 @@ def get_workflow_states(self) -> StateSchema:
class TestSignal(unittest.TestCase):
@classmethod
def setUpClass(cls):
wf = WaitWorkflow()
wf = WaitSignalWorkflow()
registry.add_workflow(wf)
cls.client = Client(registry)

def test_signal(self):
wf_id = f"{inspect.currentframe().f_code.co_name}-{time.time_ns()}"
self.client.start_workflow(WaitWorkflow, wf_id, 1)
self.client.start_workflow(WaitSignalWorkflow, wf_id, 1)
self.client.signal_workflow(wf_id, test_channel_int, 123)
self.client.signal_workflow(wf_id, test_channel_str, "abc")
self.client.signal_workflow(wf_id, test_channel_none)
Expand Down
16 changes: 8 additions & 8 deletions iwf/tests/test_workflow_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,20 @@ def execute(
return StateDecision.graceful_complete_workflow()


class WaitWorkflow(ObjectWorkflow):
class WaitInternalChannelWorkflow(ObjectWorkflow):
def get_workflow_states(self) -> StateSchema:
return StateSchema.with_starting_state(WaitState())


wf = WaitWorkflow()
wf = WaitInternalChannelWorkflow()
registry.add_workflow(wf)
client = Client(registry)


class TestWorkflowErrors(unittest.TestCase):
def test_workflow_timeout(self):
wf_id = f"{inspect.currentframe().f_code.co_name}-{time.time_ns()}"
client.start_workflow(WaitWorkflow, wf_id, 1)
client.start_workflow(WaitInternalChannelWorkflow, wf_id, 1)
with self.assertRaises(WorkflowTimeout):
client.get_simple_workflow_result_with_wait(wf_id, str)
with self.assertRaises(WorkflowNotExistsError):
Expand All @@ -76,24 +76,24 @@ def test_workflow_still_running_when_wait(self):
# client_options = ClientOptions.local_default()
# client_options.api_timeout = 5
# TODO using a shorter api timeout will throw a different timeout eror, it's better to unify it
client.start_workflow(WaitWorkflow, wf_id, 61)
client.start_workflow(WaitInternalChannelWorkflow, wf_id, 61)

with self.assertRaises(WorkflowAlreadyStartedError):
client.start_workflow(WaitWorkflow, wf_id, 61)
client.start_workflow(WaitInternalChannelWorkflow, wf_id, 61)

with self.assertRaises(WorkflowStillRunningError):
client.get_simple_workflow_result_with_wait(wf_id, str)

def test_workflow_canceled(self):
wf_id = f"{inspect.currentframe().f_code.co_name}-{time.time_ns()}"
client.start_workflow(WaitWorkflow, wf_id, 10)
client.start_workflow(WaitInternalChannelWorkflow, wf_id, 10)
client.stop_workflow(wf_id)
with self.assertRaises(WorkflowCanceled):
client.get_simple_workflow_result_with_wait(wf_id, str)

def test_workflow_terminated(self):
wf_id = f"{inspect.currentframe().f_code.co_name}-{time.time_ns()}"
client.start_workflow(WaitWorkflow, wf_id, 10)
client.start_workflow(WaitInternalChannelWorkflow, wf_id, 10)
client.stop_workflow(
wf_id,
StopWorkflowOptions(
Expand All @@ -105,7 +105,7 @@ def test_workflow_terminated(self):

def test_workflow_failed(self):
wf_id = f"{inspect.currentframe().f_code.co_name}-{time.time_ns()}"
client.start_workflow(WaitWorkflow, wf_id, 10)
client.start_workflow(WaitInternalChannelWorkflow, wf_id, 10)
client.stop_workflow(
wf_id,
StopWorkflowOptions(
Expand Down

0 comments on commit 5d16708

Please sign in to comment.