Пример #1
0
def test_execute_command_wrapper_failing_command(instance):
    with pytest.raises(ZeroDivisionError):
        execute_command_wrapper(lambda *args, **kwargs: 1 / 0, instance,
                                ["SET", {
                                    "a": 1
                                }], {})

    spans = SpansContainer.get_span().spans
    assert len(spans) == 1
    assert spans[0]["requestCommand"] == "SET"
    assert spans[0]["ended"] >= spans[0]["started"]
    assert spans[0]["error"] == "division by zero"
    assert "response" not in spans[0]
Пример #2
0
def test_execute_command_wrapper_happy_flow(instance):
    result = execute_command_wrapper(func, instance, ["SET", {
        "a": 1
    }, "b"], {})

    spans = SpansContainer.get_span().spans
    assert len(spans) == 1
    assert spans[0]["requestCommand"] == "SET"
    assert spans[0]["requestArgs"] == '[{"a": 1}, "b"]'
    assert spans[0]["connectionOptions"] == {"host": "lumigo", "port": None}
    assert spans[0]["ended"] >= spans[0]["started"]
    assert spans[0]["response"] == '"Result"'
    assert "error" not in spans[0]
    assert result == FUNCTION_RESULT
Пример #3
0
def test_execute_command_wrapper_non_json(instance):
    result = execute_command_wrapper(lambda *args, **kwargs: datetime.now(),
                                     instance, ["SET", {
                                         "a": 1
                                     }, "b"], {})

    spans = SpansContainer.get_span().spans
    assert len(spans) == 1
    assert spans[0]["requestCommand"] == "SET"
    assert spans[0]["requestArgs"] == '[{"a": 1}, "b"]'
    assert spans[0]["connectionOptions"] == {"host": "lumigo", "port": None}
    assert spans[0]["ended"] >= spans[0]["started"]
    assert spans[0]["response"]
    assert "error" not in spans[0]
    assert isinstance(result, datetime)
Пример #4
0
def test_execute_command_wrapper_unexpected_params(instance):
    result = execute_command_wrapper(func, instance, {"not": "list"}, {})

    spans = SpansContainer.get_span().spans
    assert len(spans) == 0
    assert result == FUNCTION_RESULT