Пример #1
0
def test_custom_method_name_fqn_true():
    my_class = MyClass()

    os.environ["AUTODYNATRACE_CUSTOM_SERVICE_USE_FQN"] = "TRUE"
    os.environ.pop("AUTODYNATRACE_CUSTOM_SERVICE_NAME", None)
    assert custom_wrapper.generate_method_name(
        module_function) == "tests.test_custom.module_function"
    assert custom_wrapper.generate_method_name(
        my_class.class_method) == "tests.test_custom.MyClass.class_method"
    assert custom_wrapper.generate_method_name(
        another_function) == "tests.test_custom.another_function"

    os.environ["AUTODYNATRACE_CUSTOM_SERVICE_NAME"] = "CustomServiceName"
    assert custom_wrapper.generate_method_name(
        module_function) == "tests.test_custom.module_function"
    assert custom_wrapper.generate_method_name(
        my_class.class_method) == "tests.test_custom.MyClass.class_method"
    assert custom_wrapper.generate_method_name(
        another_function) == "tests.test_custom.another_function"

    if sys.version_info[0] == 2:
        assert custom_wrapper.generate_method_name(
            my_class.static_method) == "tests.test_custom.static_method"
        assert custom_wrapper.generate_method_name(
            MyClass.static_method) == "tests.test_custom.static_method"
    else:
        assert custom_wrapper.generate_method_name(
            my_class.static_method
        ) == "tests.test_custom.MyClass.static_method"
        assert custom_wrapper.generate_method_name(
            MyClass.static_method) == "tests.test_custom.MyClass.static_method"
Пример #2
0
def test_decorator_with_arguments():
    assert custom_wrapper.generate_service_name(module_function, "Service") == "Service"
    assert custom_wrapper.generate_method_name(module_function, "method") == "method"