@@ -99,15 +99,11 @@ def test_batch_w_alternate_client(self):
9999 self .assertIs (batch .client , client2 )
100100
101101 def test_log_empty_defaults_w_default_labels (self ):
102- from google .cloud .logging_v2 .handlers ._monitored_resources import (
103- detect_resource ,
104- )
105-
106102 DEFAULT_LABELS = {"foo" : "spam" }
107103 ENTRIES = [
108104 {
109105 "logName" : "projects/%s/logs/%s" % (self .PROJECT , self .LOGGER_NAME ),
110- "resource" : detect_resource ( self . PROJECT ). _to_dict () ,
106+ "resource" : { "type" : "global" , "labels" : {}} ,
111107 "labels" : DEFAULT_LABELS ,
112108 }
113109 ]
@@ -174,11 +170,7 @@ def test_log_empty_w_explicit(self):
174170 self .assertEqual (api ._write_entries_called_with , (ENTRIES , None , None , None ))
175171
176172 def test_log_text_defaults (self ):
177- from google .cloud .logging_v2 .handlers ._monitored_resources import (
178- detect_resource ,
179- )
180-
181- RESOURCE = detect_resource (self .PROJECT )._to_dict ()
173+ RESOURCE = {"type" : "global" , "labels" : {}}
182174 TEXT = "TEXT"
183175 ENTRIES = [
184176 {
@@ -196,12 +188,8 @@ def test_log_text_defaults(self):
196188 self .assertEqual (api ._write_entries_called_with , (ENTRIES , None , None , None ))
197189
198190 def test_log_text_w_unicode_and_default_labels (self ):
199- from google .cloud .logging_v2 .handlers ._monitored_resources import (
200- detect_resource ,
201- )
202-
203191 TEXT = "TEXT"
204- RESOURCE = detect_resource ( self . PROJECT ). _to_dict ()
192+ RESOURCE = { "type" : "global" , "labels" : {}}
205193 DEFAULT_LABELS = {"foo" : "spam" }
206194 ENTRIES = [
207195 {
@@ -277,12 +265,8 @@ def test_log_text_explicit(self):
277265 self .assertEqual (api ._write_entries_called_with , (ENTRIES , None , None , None ))
278266
279267 def test_log_struct_defaults (self ):
280- from google .cloud .logging_v2 .handlers ._monitored_resources import (
281- detect_resource ,
282- )
283-
284268 STRUCT = {"message" : "MESSAGE" , "weather" : "cloudy" }
285- RESOURCE = detect_resource ( self . PROJECT ). _to_dict ()
269+ RESOURCE = { "type" : "global" , "labels" : {}}
286270 ENTRIES = [
287271 {
288272 "logName" : "projects/%s/logs/%s" % (self .PROJECT , self .LOGGER_NAME ),
@@ -299,12 +283,8 @@ def test_log_struct_defaults(self):
299283 self .assertEqual (api ._write_entries_called_with , (ENTRIES , None , None , None ))
300284
301285 def test_log_struct_w_default_labels (self ):
302- from google .cloud .logging_v2 .handlers ._monitored_resources import (
303- detect_resource ,
304- )
305-
306286 STRUCT = {"message" : "MESSAGE" , "weather" : "cloudy" }
307- RESOURCE = detect_resource ( self . PROJECT ). _to_dict ()
287+ RESOURCE = { "type" : "global" , "labels" : {}}
308288 DEFAULT_LABELS = {"foo" : "spam" }
309289 ENTRIES = [
310290 {
@@ -383,16 +363,13 @@ def test_log_proto_defaults(self):
383363 import json
384364 from google .protobuf .json_format import MessageToJson
385365 from google .protobuf .struct_pb2 import Struct , Value
386- from google .cloud .logging_v2 .handlers ._monitored_resources import (
387- detect_resource ,
388- )
389366
390367 message = Struct (fields = {"foo" : Value (bool_value = True )})
391368 ENTRIES = [
392369 {
393370 "logName" : "projects/%s/logs/%s" % (self .PROJECT , self .LOGGER_NAME ),
394371 "protoPayload" : json .loads (MessageToJson (message )),
395- "resource" : detect_resource ( self . PROJECT ). _to_dict () ,
372+ "resource" : { "type" : "global" , "labels" : {}} ,
396373 }
397374 ]
398375 client = _Client (self .PROJECT )
@@ -407,17 +384,14 @@ def test_log_proto_w_default_labels(self):
407384 import json
408385 from google .protobuf .json_format import MessageToJson
409386 from google .protobuf .struct_pb2 import Struct , Value
410- from google .cloud .logging_v2 .handlers ._monitored_resources import (
411- detect_resource ,
412- )
413387
414388 message = Struct (fields = {"foo" : Value (bool_value = True )})
415389 DEFAULT_LABELS = {"foo" : "spam" }
416390 ENTRIES = [
417391 {
418392 "logName" : "projects/%s/logs/%s" % (self .PROJECT , self .LOGGER_NAME ),
419393 "protoPayload" : json .loads (MessageToJson (message )),
420- "resource" : detect_resource ( self . PROJECT ). _to_dict () ,
394+ "resource" : { "type" : "global" , "labels" : {}} ,
421395 "labels" : DEFAULT_LABELS ,
422396 }
423397 ]
0 commit comments