def test_empty_input_if_then(): def _fn_cond(x): return x == 0 def _fn_then(x): return x + 1 operation = substitution(["a"], replace_if_else(_fn_cond, _fn_then)) (res, err) = operation(None) assert res is None assert err == {'a': 'a not found'}
def test_cond_true_replace_if_then_default_else(): def _fn_cond(x): return x == 0 def _fn_then(x): return x + 1 operation = substitution(["a"], replace_if_else(_fn_cond, _fn_then)) (res, err) = operation({"a": 100}) assert res is not None assert "a" in res assert res["a"] == 100 assert err is None