diff --git a/noxfile.py b/noxfile.py index ca8c157d19b..56f56b8b63f 100644 --- a/noxfile.py +++ b/noxfile.py @@ -52,11 +52,13 @@ def test_with_only_required_packages(session: nox.Session): # Logger # Metrics - Amazon CloudWatch EMF # Metrics - Base provider + # Middleware factory without tracer build_and_run_test( session, folders=[ f"{PREFIX_TESTS_FUNCTIONAL}/logger/required_dependencies/", f"{PREFIX_TESTS_FUNCTIONAL}/metrics/required_dependencies/", + f"{PREFIX_TESTS_FUNCTIONAL}/middleware_factory/required_dependencies/", ], ) @@ -78,10 +80,12 @@ def test_with_datadog_as_required_package(session: nox.Session): def test_with_xray_sdk_as_required_package(session: nox.Session): """Tests that depends on AWS XRAY SDK library""" # Tracer + # Middleware factory with tracer build_and_run_test( session, folders=[ - f"{PREFIX_TESTS_FUNCTIONAL}/tracing/aws_xray_sdk/", + f"{PREFIX_TESTS_FUNCTIONAL}/tracer/_aws_xray_sdk/", + f"{PREFIX_TESTS_FUNCTIONAL}/middleware_factory/_aws_xray_sdk/", ], extras="tracer", ) diff --git a/tests/functional/tracing/__init__.py b/tests/functional/middleware_factory/_aws_xray_sdk/__init__.py similarity index 100% rename from tests/functional/tracing/__init__.py rename to tests/functional/middleware_factory/_aws_xray_sdk/__init__.py diff --git a/tests/functional/middleware_factory/_aws_xray_sdk/test_middleware_factory_tracing.py b/tests/functional/middleware_factory/_aws_xray_sdk/test_middleware_factory_tracing.py new file mode 100644 index 00000000000..0e19ac39aa3 --- /dev/null +++ b/tests/functional/middleware_factory/_aws_xray_sdk/test_middleware_factory_tracing.py @@ -0,0 +1,32 @@ +from aws_lambda_powertools.middleware_factory import lambda_handler_decorator + + +def test_factory_explicit_tracing(monkeypatch): + monkeypatch.setenv("POWERTOOLS_TRACE_DISABLED", "true") + + @lambda_handler_decorator(trace_execution=True) + def no_op(handler, event, context): + ret = handler(event, context) + return ret + + @no_op + def lambda_handler(evt, ctx): + return True + + lambda_handler({}, {}) + + +def test_factory_explicit_tracing_env_var(monkeypatch): + monkeypatch.setenv("POWERTOOLS_TRACE_MIDDLEWARES", "true") + monkeypatch.setenv("POWERTOOLS_TRACE_DISABLED", "true") + + @lambda_handler_decorator + def no_op(handler, event, context): + ret = handler(event, context) + return ret + + @no_op + def lambda_handler(evt, ctx): + return True + + lambda_handler({}, {}) diff --git a/tests/functional/tracing/aws_xray_sdk/__init__.py b/tests/functional/middleware_factory/required_dependencies/__init__.py similarity index 100% rename from tests/functional/tracing/aws_xray_sdk/__init__.py rename to tests/functional/middleware_factory/required_dependencies/__init__.py diff --git a/tests/functional/test_middleware_factory.py b/tests/functional/middleware_factory/required_dependencies/test_middleware_factory.py similarity index 80% rename from tests/functional/test_middleware_factory.py rename to tests/functional/middleware_factory/required_dependencies/test_middleware_factory.py index fb868cef0ee..7481e2b8f6b 100644 --- a/tests/functional/test_middleware_factory.py +++ b/tests/functional/middleware_factory/required_dependencies/test_middleware_factory.py @@ -62,37 +62,6 @@ def lambda_handler(evt, ctx): lambda_handler({}, {}) -def test_factory_explicit_tracing(monkeypatch): - monkeypatch.setenv("POWERTOOLS_TRACE_DISABLED", "true") - - @lambda_handler_decorator(trace_execution=True) - def no_op(handler, event, context): - ret = handler(event, context) - return ret - - @no_op - def lambda_handler(evt, ctx): - return True - - lambda_handler({}, {}) - - -def test_factory_explicit_tracing_env_var(monkeypatch): - monkeypatch.setenv("POWERTOOLS_TRACE_MIDDLEWARES", "true") - monkeypatch.setenv("POWERTOOLS_TRACE_DISABLED", "true") - - @lambda_handler_decorator - def no_op(handler, event, context): - ret = handler(event, context) - return ret - - @no_op - def lambda_handler(evt, ctx): - return True - - lambda_handler({}, {}) - - def test_factory_decorator_with_kwarg_params(capsys): @lambda_handler_decorator def log_event(handler, event, context, log_event=False): diff --git a/tests/functional/tracer/__init__.py b/tests/functional/tracer/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/functional/tracer/_aws_xray_sdk/__init__.py b/tests/functional/tracer/_aws_xray_sdk/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/functional/tracing/aws_xray_sdk/test_tracing.py b/tests/functional/tracer/_aws_xray_sdk/test_tracing.py similarity index 100% rename from tests/functional/tracing/aws_xray_sdk/test_tracing.py rename to tests/functional/tracer/_aws_xray_sdk/test_tracing.py