@@ -99,15 +99,11 @@ def test_batch_w_alternate_client(self):
99
99
self .assertIs (batch .client , client2 )
100
100
101
101
def test_log_empty_defaults_w_default_labels (self ):
102
- from google .cloud .logging_v2 .handlers ._monitored_resources import (
103
- detect_resource ,
104
- )
105
-
106
102
DEFAULT_LABELS = {"foo" : "spam" }
107
103
ENTRIES = [
108
104
{
109
105
"logName" : "projects/%s/logs/%s" % (self .PROJECT , self .LOGGER_NAME ),
110
- "resource" : detect_resource ( self . PROJECT ). _to_dict () ,
106
+ "resource" : { "type" : "global" , "labels" : {}} ,
111
107
"labels" : DEFAULT_LABELS ,
112
108
}
113
109
]
@@ -174,11 +170,7 @@ def test_log_empty_w_explicit(self):
174
170
self .assertEqual (api ._write_entries_called_with , (ENTRIES , None , None , None ))
175
171
176
172
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" : {}}
182
174
TEXT = "TEXT"
183
175
ENTRIES = [
184
176
{
@@ -196,12 +188,8 @@ def test_log_text_defaults(self):
196
188
self .assertEqual (api ._write_entries_called_with , (ENTRIES , None , None , None ))
197
189
198
190
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
-
203
191
TEXT = "TEXT"
204
- RESOURCE = detect_resource ( self . PROJECT ). _to_dict ()
192
+ RESOURCE = { "type" : "global" , "labels" : {}}
205
193
DEFAULT_LABELS = {"foo" : "spam" }
206
194
ENTRIES = [
207
195
{
@@ -277,12 +265,8 @@ def test_log_text_explicit(self):
277
265
self .assertEqual (api ._write_entries_called_with , (ENTRIES , None , None , None ))
278
266
279
267
def test_log_struct_defaults (self ):
280
- from google .cloud .logging_v2 .handlers ._monitored_resources import (
281
- detect_resource ,
282
- )
283
-
284
268
STRUCT = {"message" : "MESSAGE" , "weather" : "cloudy" }
285
- RESOURCE = detect_resource ( self . PROJECT ). _to_dict ()
269
+ RESOURCE = { "type" : "global" , "labels" : {}}
286
270
ENTRIES = [
287
271
{
288
272
"logName" : "projects/%s/logs/%s" % (self .PROJECT , self .LOGGER_NAME ),
@@ -299,12 +283,8 @@ def test_log_struct_defaults(self):
299
283
self .assertEqual (api ._write_entries_called_with , (ENTRIES , None , None , None ))
300
284
301
285
def test_log_struct_w_default_labels (self ):
302
- from google .cloud .logging_v2 .handlers ._monitored_resources import (
303
- detect_resource ,
304
- )
305
-
306
286
STRUCT = {"message" : "MESSAGE" , "weather" : "cloudy" }
307
- RESOURCE = detect_resource ( self . PROJECT ). _to_dict ()
287
+ RESOURCE = { "type" : "global" , "labels" : {}}
308
288
DEFAULT_LABELS = {"foo" : "spam" }
309
289
ENTRIES = [
310
290
{
@@ -383,16 +363,13 @@ def test_log_proto_defaults(self):
383
363
import json
384
364
from google .protobuf .json_format import MessageToJson
385
365
from google .protobuf .struct_pb2 import Struct , Value
386
- from google .cloud .logging_v2 .handlers ._monitored_resources import (
387
- detect_resource ,
388
- )
389
366
390
367
message = Struct (fields = {"foo" : Value (bool_value = True )})
391
368
ENTRIES = [
392
369
{
393
370
"logName" : "projects/%s/logs/%s" % (self .PROJECT , self .LOGGER_NAME ),
394
371
"protoPayload" : json .loads (MessageToJson (message )),
395
- "resource" : detect_resource ( self . PROJECT ). _to_dict () ,
372
+ "resource" : { "type" : "global" , "labels" : {}} ,
396
373
}
397
374
]
398
375
client = _Client (self .PROJECT )
@@ -407,17 +384,14 @@ def test_log_proto_w_default_labels(self):
407
384
import json
408
385
from google .protobuf .json_format import MessageToJson
409
386
from google .protobuf .struct_pb2 import Struct , Value
410
- from google .cloud .logging_v2 .handlers ._monitored_resources import (
411
- detect_resource ,
412
- )
413
387
414
388
message = Struct (fields = {"foo" : Value (bool_value = True )})
415
389
DEFAULT_LABELS = {"foo" : "spam" }
416
390
ENTRIES = [
417
391
{
418
392
"logName" : "projects/%s/logs/%s" % (self .PROJECT , self .LOGGER_NAME ),
419
393
"protoPayload" : json .loads (MessageToJson (message )),
420
- "resource" : detect_resource ( self . PROJECT ). _to_dict () ,
394
+ "resource" : { "type" : "global" , "labels" : {}} ,
421
395
"labels" : DEFAULT_LABELS ,
422
396
}
423
397
]
0 commit comments