Skip to content

Commit 82ea24a

Browse files
committed
Refactor fake credentials to enable reuse.
1 parent 9d5b390 commit 82ea24a

File tree

2 files changed

+22
-6
lines changed
  • instrumentation-genai/opentelemetry-instrumentation-google-genai/tests/common

2 files changed

+22
-6
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
import google.auth
16+
17+
class FakeCredentials(google.auth.credentials.AnonymousCredentials):
18+
19+
def refresh(self, request):
20+
pass

instrumentation-genai/opentelemetry-instrumentation-google-genai/tests/common/base.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,11 @@
1717

1818
import google.genai
1919

20+
from .auth import FakeCredentials
2021
from .instrumentation_context import InstrumentationContext
2122
from .otel_mocker import OTelMocker
2223

2324

24-
class _FakeCredentials(google.auth.credentials.AnonymousCredentials):
25-
def refresh(self, request):
26-
pass
27-
28-
2925
class TestCase(unittest.TestCase):
3026
def setUp(self):
3127
self._otel = OTelMocker()
@@ -36,7 +32,7 @@ def setUp(self):
3632
self._location = "test-location"
3733
self._client = None
3834
self._uses_vertex = False
39-
self._credentials = _FakeCredentials()
35+
self._credentials = FakeCredentials()
4036

4137
def _lazy_init(self):
4238
self._instrumentation_context = InstrumentationContext()

0 commit comments

Comments
 (0)