def test_condition(): task = tasks.Condition( name="condition", preconditions=validators.is_equal(value_key="$.value", validator_value="a"), conditions=validators.is_equal(value_key="$.another_value", validator_value="b"), on_success=containers.TaskTarget( flow_name="Base", task_name="SuccessTask", ), success_message=containers.Message( template="You we're successful", message_type="success", ), on_failure=containers.TaskTarget( flow_name="Base", task_name="FailureTask", ), failure_message=containers.Message( template="Failure", message_type="error", ), ) validator = get_validator_for("tasks/condition") validator.validate(task.as_dict())
def test_wait(): task = tasks.Wait( name="wait", url="/endpoint/task/url", timeout="12000", conditions=validators.is_equal(value_key="$.value", validator_value="a"), method="GET", payload_paths=[ { "key": "$.arg1", "result_key": "$.arg1_result" }, { "key": "$.arg2", "result_key": "$.arg2_result" }, ], payload={ "arg1_result": None, "arg2_result": None }, response_path="$.response", ) validator = get_validator_for("tasks/wait") validator.validate(task.as_dict())
def test_flow_to_dict(flow): task = flow.add_task( task_type="jsonrpc", name="task", url="/endpoint/task/url", preconditions=validators.is_equal(value_key="$.value", validator_value="a"), method="GET", payload_paths=[ { "key": "$.arg1", "result_key": "$.arg1_result" }, { "key": "$.arg2", "result_key": "$.arg2_result" }, ], payload={ "arg1_result": None, "arg2_result": None }, response_path="$.response", ) validator = get_validator_for("tasks/flow") validator.validate(flow.as_dict())
def test_jsonrpc(): task = tasks.JsonRpc( name="task", url="/endpoint/task/url", preconditions=validators.is_equal(value_key="$.value", validator_value="a"), method="GET", payload_paths=[ { "key": "$.arg1", "result_key": "$.arg1_result" }, { "key": "$.arg2", "result_key": "$.arg2_result" }, ], payload={ "arg1_result": None, "arg2_result": None }, response_path="$.response", ) validator = get_validator_for("tasks/jsonrpc") validator.validate(task.as_dict())
def test_clear_domain_params(): task = tasks.ClearDomainParams( name="clear_domain_params", preconditions=validators.is_equal(value_key="$.value", validator_value="a"), ) validator = get_validator_for("tasks/clear_domain_params") validator.validate(task.as_dict())
def test_redirect(): task = tasks.Redirect( name="redirect", preconditions=validators.is_equal(value_key="$.value", validator_value="a"), url="url/to/go/to", ) validator = get_validator_for("tasks/redirect") validator.validate(task.as_dict())
def test_local_store(): task = tasks.LocalStore( name="local_store", preconditions=validators.is_equal(value_key="$.value", validator_value="a"), context_path="$.local_value", storage_key="store_key", ) validator = get_validator_for("tasks/set_local_storage") validator.validate(task.as_dict())
def test_event(): task = tasks.Event( name="event", preconditions=validators.is_equal(value_key="$.value", validator_value="a"), action="break", payload={"X": "Y"}, ) validator = get_validator_for("tasks/event") validator.validate(task.as_dict())
def test_set_domain_param(): task = tasks.DomainParam( name="set_domain_param", preconditions=validators.is_equal(value_key="$.value", validator_value="a"), context_path="$.context_value", param="parameter", ) validator = get_validator_for("tasks/set_domain_param") validator.validate(task.as_dict())
def test_update(): task = tasks.Update( name="update", preconditions=validators.is_equal(value_key="$.value", validator_value="a"), tasks=[ { "key": "$.src", "result_key": "$.dest" }, { "result": True, "result_key": "$.dest" }, { "template": "This is the source: {$.src}", "result_key": "$.dest" }, ], ) validator = get_validator_for("tasks/update") validator.validate(task.as_dict())
def flow(self): self.add_task( task_type="jsonrpc", name="task", url="/endpoint/task/url", preconditions=validators.is_equal(value_key="$.value", validator_value="a"), method="GET", payload_paths=[ { "key": "$.arg1", "result_key": "$.arg1_result" }, { "key": "$.arg2", "result_key": "$.arg2_result" }, ], payload={ "arg1_result": None, "arg2_result": None }, response_path="$.response", )