Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): add the Middleware Factory feature to nox tests #4568

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
],
)

Expand All @@ -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}/tracing/_aws_xray_sdk/",
f"{PREFIX_TESTS_FUNCTIONAL}/middleware_factory/_aws_xray_sdk/",
],
extras="tracer",
)
Original file line number Diff line number Diff line change
@@ -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({}, {})
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Empty file.