1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15- import mock
1615import pytest
17- import unittest
1816
1917from . import _helpers
20- from google .cloud .spanner_v1 import Client , DirectedReadOptions
18+ from google .cloud .spanner_v1 import Client
2119
2220HAS_OTEL_INSTALLED = False
2321
3533 pass
3634
3735
38- @pytest .mark .skipif (not HAS_OTEL_INSTALLED , reason = "OpenTelemetry needed." )
39- @pytest .mark .skipif (not _helpers .USE_EMULATOR , reason = "Emulator needed." )
36+ @pytest .mark .skipif (
37+ not HAS_OTEL_INSTALLED , reason = "OpenTelemetry is necessary to test traces."
38+ )
39+ @pytest .mark .skipif (
40+ not _helpers .USE_EMULATOR , reason = "mulator is necessary to test traces."
41+ )
4042def test_observability_options_propagation ():
4143 PROJECT = _helpers .EMULATOR_PROJECT
42- PATH = "projects/%s" % (PROJECT ,)
4344 CONFIGURATION_NAME = "config-name"
4445 INSTANCE_ID = _helpers .INSTANCE_ID
45- INSTANCE_NAME = "%s/instances/%s" % (PATH , INSTANCE_ID )
4646 DISPLAY_NAME = "display-name"
4747 DATABASE_ID = _helpers .unique_id ("temp_db" )
4848 NODE_COUNT = 5
49- PROCESSING_UNITS = 5000
5049 LABELS = {"test" : "true" }
51- TIMEOUT_SECONDS = 80
52- LEADER_OPTIONS = ["leader1" , "leader2" ]
53- DIRECTED_READ_OPTIONS = {
54- "include_replicas" : {
55- "replica_selections" : [
56- {
57- "location" : "us-west1" ,
58- "type_" : DirectedReadOptions .ReplicaSelection .Type .READ_ONLY ,
59- },
60- ],
61- "auto_failover_disabled" : True ,
62- },
63- }
6450
6551 def test_propagation (enable_extended_tracing ):
6652 global_tracer_provider = TracerProvider (sampler = ALWAYS_ON )
@@ -95,13 +81,13 @@ def test_propagation(enable_extended_tracing):
9581
9682 try :
9783 instance .create ()
98- except :
84+ except Exception :
9985 pass
10086
10187 db = instance .database (DATABASE_ID )
10288 try :
10389 db .create ()
104- except :
90+ except Exception :
10591 pass
10692
10793 assert db .observability_options == observability_options
@@ -134,7 +120,7 @@ def test_propagation(enable_extended_tracing):
134120 try :
135121 db .delete ()
136122 instance .delete ()
137- except :
123+ except Exception :
138124 pass
139125
140126 # Test the respective options for enable_extended_tracing
@@ -143,11 +129,5 @@ def test_propagation(enable_extended_tracing):
143129
144130
145131def _make_credentials ():
146- import google .auth .credentials
147-
148- class _CredentialsWithScopes (
149- google .auth .credentials .Credentials , google .auth .credentials .Scoped
150- ):
151- pass
152-
153- return mock .Mock (spec = _CredentialsWithScopes )
132+ from google .auth .credentials import AnonymousCredentials
133+ return AnonymousCredentials ()
0 commit comments