Skip to content

Commit 1d0db15

Browse files
committed
tests
1 parent 47c172f commit 1d0db15

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright The OpenTelemetry Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from unittest import mock, TestCase
16+
from opentelemetry.instrumentation.celery import CarrierGetter
17+
18+
class TestCarrierGetter(TestCase):
19+
def test_get_none(self):
20+
getter = CarrierGetter()
21+
carrier = {}
22+
val = getter.get(carrier, "test")
23+
self.assertIsNone(val)
24+
25+
def test_get_str(self):
26+
mock_obj = mock.Mock()
27+
getter = CarrierGetter()
28+
mock_obj.test = "val"
29+
val = getter.get(mock_obj, "test")
30+
self.assertEqual(val, ("val",))
31+
32+
def test_get_iter(self):
33+
mock_obj = mock.Mock()
34+
getter = CarrierGetter()
35+
mock_obj.test = ["val"]
36+
val = getter.get(mock_obj, "test")
37+
self.assertEqual(val, ["val"])
38+
39+
def test_keys(self):
40+
getter = CarrierGetter()
41+
keys = getter.keys({})
42+
self.assertEqual(keys, [])
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright The OpenTelemetry Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from unittest import mock, TestCase
16+
from opentelemetry.instrumentation.wsgi import CarrierGetter
17+
18+
class TestCarrierGetter(TestCase):
19+
def test_get_none(self):
20+
getter = CarrierGetter()
21+
carrier = {}
22+
val = getter.get(carrier, "test")
23+
self.assertIsNone(val)
24+
25+
def test_get_(self):
26+
getter = CarrierGetter()
27+
carrier = {"HTTP_TEST_KEY":"val"}
28+
val = getter.get(carrier, "test-key")
29+
self.assertEqual(val, ["val"])
30+
31+
def test_keys(self):
32+
getter = CarrierGetter()
33+
keys = getter.keys({})
34+
self.assertEqual(keys, [])

0 commit comments

Comments
 (0)