def test_that_checks_input_wrapping(): eleven = number_node(11) twentytwo = number_node(22) check = check_values_in_dict_node() check.connect_input(dictionary=wrap({"a": eleven, "b": [33, twentytwo]})) check.trigger() assert check["out"].get() is True
def extract_from_list_node(list_input: list, index: int, error_message: Optional(str)) -> Any(): try: return wrap(list_input[index]) except Exception as e: if error_message is not None: raise Exception(error_message.format(e)) else: raise e
def report_node(*args: Any) -> report_result: report = "" success = True for assertion_result in args: message = assertion_result["message"] result = assertion_result["result"] report += f"{message}: {result}\n" if not assertion_result["result"]: success = False report = f"Passed: {success}\n{report}" return wrap({"passed": success, "report": report})
def extract_item_with_filter_node(list_input: list, key: str, to_match: Any()) -> Any(): for item in list_input: try: if item[key] == to_match: return wrap(item) except Exception: raise Exception( f"List {list_input} does not contain requested key {key}") raise Exception( f"List {list_input} does not contain item with {key} equal to {to_match}" )
def extensible_node(*args: Any, **kwargs: Any) -> {"out": int, "e": int}: return wrap({"e": sum(kwargs.values()), "out": 666})
def http_test_node(code: int) -> http_result: return wrap({"_HttpCode": code})
def decompose_node(item: Any()): return wrap(item)
def weird_node() -> {"api_name": str, "env": str}: return wrap({"api_name": "telemetry", "env": "prd"})
def dummy_with_wrong_outputs_node() -> {"a": int, "c": int}: return wrap({"a": 22, "b": 11})
def dummy_with_chaotic_outputs(power: int): return wrap([x**power for x in range(22)])
def dummy_with_inputs_node(a: int, b: str, c: bool) -> (int, float): print("a", a, "b", b, "c", c) return wrap((a * 2 if c else a * 3, float(int(b, 16)) / 2.5))
def dummy_node_with_convenient_outputs() -> (int, str, bool): return wrap((1, "2", True))
def dummy_with_dict_output() -> {"first": int, "second": str, "third": str}: return wrap({"first": 3, "second": "Hello", "third": "AB"})
def dummy_with_list_output() -> [str, str, str]: return wrap(["Sword", "Shield", "TREBUCHET"])
def dummy_with_tuple_output() -> (int, int, int, int): return wrap((1, 2, 3, 4))
def dummy_with_optional_output_node() -> {"a": int, OptionalKey("b"): str}: return wrap({"a": 5})