Skip to content

Commit

Permalink
Update tests with code review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
odeke-em committed Jan 9, 2025
1 parent ea2551a commit cd7d1ed
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 31 deletions.
3 changes: 0 additions & 3 deletions tests/unit/test_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1230,9 +1230,6 @@ def test_partition_read_other_error(self):
with self.assertRaises(RuntimeError):
list(derived.partition_read(TABLE_NAME, COLUMNS, keyset))

if not HAS_OPENTELEMETRY_INSTALLED:
return

self.assertSpanAttributes(
"CloudSpanner._Derived.partition_read",
status=StatusCode.ERROR,
Expand Down
28 changes: 0 additions & 28 deletions tests/unit/test_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from google.api_core import gapic_v1

from tests._helpers import (
HAS_OPENTELEMETRY_INSTALLED,
OpenTelemetryBase,
StatusCode,
enrich_with_otel_scope,
Expand Down Expand Up @@ -162,14 +161,6 @@ def test_begin_w_other_error(self):
with self.assertRaises(RuntimeError):
transaction.begin()

if not HAS_OPENTELEMETRY_INSTALLED:
return

span_list = self.get_finished_spans()
got_span_names = [span.name for span in span_list]
want_span_names = ["CloudSpanner.Transaction.begin"]
assert got_span_names == want_span_names

self.assertSpanAttributes(
"CloudSpanner.Transaction.begin",
status=StatusCode.ERROR,
Expand Down Expand Up @@ -354,23 +345,10 @@ def test_commit_w_other_error(self):

self.assertIsNone(transaction.committed)

if not HAS_OPENTELEMETRY_INSTALLED:
return

span_list = sorted(self.get_finished_spans(), key=lambda v: v.start_time)
got_span_names = [span.name for span in span_list]
want_span_names = [
"CloudSpanner.Transaction.commit",
]
assert got_span_names == want_span_names

txn_commit_span = span_list[-1]

self.assertSpanAttributes(
"CloudSpanner.Transaction.commit",
status=StatusCode.ERROR,
attributes=dict(TestTransaction.BASE_ATTRIBUTES, num_mutations=1),
span=txn_commit_span,
)

def _commit_helper(
Expand Down Expand Up @@ -449,18 +427,12 @@ def _commit_helper(
if return_commit_stats:
self.assertEqual(transaction.commit_stats.mutation_count, 4)

if not HAS_OPENTELEMETRY_INSTALLED:
return

span_list = sorted(self.get_finished_spans(), key=lambda v: v.start_time)
txn_commit_span = span_list[-1]
self.assertSpanAttributes(
"CloudSpanner.Transaction.commit",
attributes=dict(
TestTransaction.BASE_ATTRIBUTES,
num_mutations=len(transaction._mutations),
),
span=txn_commit_span,
)

def test_commit_no_mutations(self):
Expand Down

0 comments on commit cd7d1ed

Please sign in to comment.