Skip to content

Commit fe5a19c

Browse files
committed
Add more comments to the tests.
1 parent 94ee68b commit fe5a19c

File tree

5 files changed

+39
-2
lines changed

5 files changed

+39
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from opentelemetry.instrumentation.google_genai import ( # pylint: disable=wrong-import-position
15+
from opentelemetry.instrumentation.google_genai import (
1616
GoogleGenAiSdkInstrumentor,
1717
)
1818

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,26 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# This file defines a "RequestMocker" that facilities mocking the "requests"
16+
# API. There are a few reasons that we use this approach to testing:
17+
#
18+
# 1. Security - although "vcrpy" provides a means of filtering data,
19+
# it can be error-prone; use of this solution risks exposing API keys,
20+
# auth tokens, etc. It can also inadvertently record fields that are
21+
# visibility-restricted (such as fields that are returned and available
22+
# when recording using privileged API keys where such fields would not
23+
# ordinarily be returned to users with non-privileged API keys).
24+
#
25+
# 2. Reproducibility - although the tests may be reproducible once the
26+
# recording is present, updating the recording often has external
27+
# dependencies that may be difficult to reproduce.
28+
#
29+
# 3. Costs - there are both time costs and monetary costs to the external
30+
# dependencies required for a record/replay solution.
31+
#
32+
# Because they APIs that need to be mocked are simple enough and well documented
33+
# enough, it seems approachable to mock the requests library, instead.
34+
1535
import copy
1636
import functools
1737
import http.client

instrumentation-genai/opentelemetry-instrumentation-google-genai/tests/generate_content/test_async_nonstreaming.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
16+
# TODO: Once the async non-streaming case has been fully implemented,
17+
# reimplement this in terms of "nonstreaming_base.py".
18+
1519
import asyncio
1620
import logging
1721
import unittest
@@ -44,6 +48,8 @@ def create_valid_response(
4448
}
4549

4650

51+
# Temporary test fixture just to ensure that the in-progress work to
52+
# implement this case doesn't break the original code.
4753
class TestGenerateContentAsyncNonstreaming(TestCase):
4854
def configure_valid_response(
4955
self,

instrumentation-genai/opentelemetry-instrumentation-google-genai/tests/generate_content/test_async_streaming.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
# TODO: once the async streaming case has been implemented, we should have
18+
# two different tests here that inherit from "streaming_base" and "nonstreaming_base",
19+
# covering the cases of one response and multiple streaming responses.
20+
1721
import asyncio
1822
import logging
1923
import unittest
@@ -46,6 +50,8 @@ def create_valid_response(
4650
}
4751

4852

53+
# Temporary test fixture just to ensure that the in-progress work to
54+
# implement this case doesn't break the original code.
4955
class TestGenerateContentAsyncStreaming(TestCase):
5056
def configure_valid_response(
5157
self,

instrumentation-genai/opentelemetry-instrumentation-google-genai/tests/generate_content/test_sync_streaming.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# TODO: once the async streaming case has been implemented, we should have
16+
# two different tests here that inherit from "streaming_base" and "nonstreaming_base",
17+
# covering the cases of one response and multiple streaming responses.
18+
1519
import logging
1620
import unittest
1721

@@ -42,7 +46,8 @@ def create_valid_response(
4246
],
4347
}
4448

45-
49+
# Temporary test fixture just to ensure that the in-progress work to
50+
# implement this case doesn't break the original code.
4651
class TestGenerateContentSyncStreaming(TestCase):
4752
def configure_valid_response(
4853
self,

0 commit comments

Comments
 (0)