|
23 | 23 | MAX_UINT_64BITS = (1 << 64) - 1 |
24 | 24 |
|
25 | 25 |
|
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): |
28 | 28 | product = MagicMock() |
29 | | - monkeypatch.setattr("datadog_lambda.config.Config.sca_enabled", sca_enabled) |
30 | 29 | monkeypatch.setitem(sys.modules, "ddtrace.internal.sca.product", product) |
31 | 30 |
|
32 | 31 | importlib.reload(wrapper) |
33 | 32 |
|
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()] |
37 | 34 |
|
38 | 35 |
|
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): |
41 | 38 | monkeypatch.setitem(sys.modules, "ddtrace.internal.sca.product", None) |
42 | 39 |
|
43 | 40 | importlib.reload(wrapper) |
44 | 41 |
|
45 | 42 |
|
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 | | - |
58 | 43 | class TestDatadogLambdaWrapper(unittest.TestCase): |
59 | 44 | def setUp(self): |
60 | 45 | # Force @datadog_lambda_wrapper to always create a real |
|
0 commit comments