Skip to content

Commit 25eb00b

Browse files
committed
test: align SCA startup coverage with other products
1 parent 99bdbe5 commit 25eb00b

1 file changed

Lines changed: 5 additions & 20 deletions

File tree

‎tests/test_wrapper.py‎

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,23 @@
2323
MAX_UINT_64BITS = (1 << 64) - 1
2424

2525

26-
@pytest.mark.parametrize("sca_enabled", [False, True])
27-
def test_sca_startup(sca_enabled, monkeypatch):
26+
@patch("datadog_lambda.config.Config.sca_enabled", True)
27+
def test_sca_enabled(monkeypatch):
2828
product = MagicMock()
29-
monkeypatch.setattr("datadog_lambda.config.Config.sca_enabled", sca_enabled)
3029
monkeypatch.setitem(sys.modules, "ddtrace.internal.sca.product", product)
3130

3231
importlib.reload(wrapper)
3332

34-
assert product.mock_calls == (
35-
[call.start(), call.post_preload()] if sca_enabled else []
36-
)
33+
assert product.mock_calls == [call.start(), call.post_preload()]
3734

3835

39-
def test_sca_startup_with_older_tracer(monkeypatch):
40-
monkeypatch.setattr("datadog_lambda.config.Config.sca_enabled", True)
36+
@patch("datadog_lambda.config.Config.sca_enabled", True)
37+
def test_sca_import_errors_caught(monkeypatch):
4138
monkeypatch.setitem(sys.modules, "ddtrace.internal.sca.product", None)
4239

4340
importlib.reload(wrapper)
4441

4542

46-
def test_sca_startup_failure_preserves_handler(monkeypatch):
47-
product = MagicMock()
48-
product.start.side_effect = RuntimeError("SCA startup failed")
49-
monkeypatch.setattr("datadog_lambda.config.Config.sca_enabled", True)
50-
monkeypatch.setitem(sys.modules, "ddtrace.internal.sca.product", product)
51-
52-
importlib.reload(wrapper)
53-
54-
product.post_preload.assert_not_called()
55-
assert callable(wrapper.datadog_lambda_wrapper)
56-
57-
5843
class TestDatadogLambdaWrapper(unittest.TestCase):
5944
def setUp(self):
6045
# Force @datadog_lambda_wrapper to always create a real

0 commit comments

Comments
 (0)