diff --git a/instrumentation/opentelemetry-instrumentation-asgi/tests/test_getter.py b/instrumentation/opentelemetry-instrumentation-asgi/tests/test_getter.py index 454162d715..26bb652b50 100644 --- a/instrumentation/opentelemetry-instrumentation-asgi/tests/test_getter.py +++ b/instrumentation/opentelemetry-instrumentation-asgi/tests/test_getter.py @@ -18,12 +18,18 @@ class TestASGIGetter(TestCase): - def test_get_none(self): + def test_get_none_empty_carrier(self): getter = ASGIGetter() carrier = {} val = getter.get(carrier, "test") self.assertIsNone(val) + def test_get_none_empty_headers(self): + getter = ASGIGetter() + carrier = {"headers": []} + val = getter.get(carrier, "test") + self.assertIsNone(val) + def test_get_(self): getter = ASGIGetter() carrier = {"headers": [(b"test-key", b"val")]} @@ -44,7 +50,22 @@ def test_get_(self): "Should be case insensitive", ) - def test_keys(self): + def test_keys_empty_carrier(self): getter = ASGIGetter() keys = getter.keys({}) self.assertEqual(keys, []) + + def test_keys_empty_headers(self): + getter = ASGIGetter() + keys = getter.keys({"headers": []}) + self.assertEqual(keys, []) + + def test_keys(self): + getter = ASGIGetter() + carrier = {"headers": [(b"test-key", b"val")]} + expected_val = ["test-key"] + self.assertEqual( + getter.keys(carrier), + expected_val, + "Should be equal", + )