@@ -744,6 +744,12 @@ def test_sink_create_ok(self):
744744 from google .cloud .proto .logging .v2 .logging_config_pb2 import LogSink
745745
746746 gax_api = _GAXSinksAPI ()
747+ gax_api ._create_sink_response = LogSink (
748+ name = self .SINK_NAME ,
749+ destination = self .DESTINATION_URI ,
750+ filter = self .FILTER ,
751+ writer_identity = self .SINK_WRITER_IDENTITY ,
752+ )
747753 api = self ._make_one (gax_api , None )
748754
749755 returned = api .sink_create (
@@ -824,6 +830,7 @@ def test_sink_update_error(self):
824830
825831 def test_sink_update_miss (self ):
826832 from google .cloud .exceptions import NotFound
833+ from google .cloud .proto .logging .v2 .logging_config_pb2 import LogSink
827834
828835 gax_api = _GAXSinksAPI ()
829836 api = self ._make_one (gax_api , None )
@@ -833,25 +840,50 @@ def test_sink_update_miss(self):
833840 self .PROJECT , self .SINK_NAME , self .FILTER ,
834841 self .DESTINATION_URI )
835842
843+ sink_name , sink , unique_writer_identity , options = (
844+ gax_api ._update_sink_called_with )
845+ self .assertEqual (sink_name , self .SINK_PATH )
846+ self .assertIsInstance (sink , LogSink )
847+ self .assertEqual (sink .name , self .SINK_PATH )
848+ self .assertEqual (sink .filter , self .FILTER )
849+ self .assertEqual (sink .destination , self .DESTINATION_URI )
850+ self .assertFalse (unique_writer_identity )
851+ self .assertIsNone (options )
852+
836853 def test_sink_update_hit (self ):
837854 from google .cloud .proto .logging .v2 .logging_config_pb2 import LogSink
838855
839- response = LogSink (name = self .SINK_NAME ,
840- destination = self .DESTINATION_URI ,
841- filter = self .FILTER )
856+ response = LogSink (
857+ name = self .SINK_NAME ,
858+ destination = self .DESTINATION_URI ,
859+ filter = self .FILTER ,
860+ writer_identity = Test_SinksAPI .SINK_WRITER_IDENTITY ,
861+ )
842862 gax_api = _GAXSinksAPI (_update_sink_response = response )
843863 api = self ._make_one (gax_api , None )
844864
845- api .sink_update (
846- self .PROJECT , self .SINK_NAME , self .FILTER , self .DESTINATION_URI )
865+ returned = api .sink_update (
866+ self .PROJECT ,
867+ self .SINK_NAME ,
868+ self .FILTER ,
869+ self .DESTINATION_URI ,
870+ unique_writer_identity = True )
847871
848- sink_name , sink , options = (
872+ self .assertEqual (returned , {
873+ 'name' : self .SINK_NAME ,
874+ 'filter' : self .FILTER ,
875+ 'destination' : self .DESTINATION_URI ,
876+ 'writerIdentity' : self .SINK_WRITER_IDENTITY ,
877+ })
878+
879+ sink_name , sink , unique_writer_identity , options = (
849880 gax_api ._update_sink_called_with )
850881 self .assertEqual (sink_name , self .SINK_PATH )
851882 self .assertIsInstance (sink , LogSink )
852883 self .assertEqual (sink .name , self .SINK_PATH )
853884 self .assertEqual (sink .filter , self .FILTER )
854885 self .assertEqual (sink .destination , self .DESTINATION_URI )
886+ self .assertTrue (unique_writer_identity )
855887 self .assertIsNone (options )
856888
857889 def test_sink_delete_error (self ):
@@ -1497,12 +1529,7 @@ def create_sink(self, parent, sink, unique_writer_identity, options):
14971529 raise GaxError ('error' )
14981530 if self ._create_sink_conflict :
14991531 raise GaxError ('conflict' , self ._make_grpc_failed_precondition ())
1500- return LogSink (
1501- name = sink .name ,
1502- destination = sink .destination ,
1503- filter = sink .filter ,
1504- writer_identity = Test_SinksAPI .SINK_WRITER_IDENTITY ,
1505- )
1532+ return self ._create_sink_response
15061533
15071534 def get_sink (self , sink_name , options ):
15081535 from google .gax .errors import GaxError
@@ -1515,10 +1542,11 @@ def get_sink(self, sink_name, options):
15151542 except AttributeError :
15161543 raise GaxError ('notfound' , self ._make_grpc_not_found ())
15171544
1518- def update_sink (self , sink_name , sink , options = None ):
1545+ def update_sink (self , sink_name , sink , unique_writer_identity , options ):
15191546 from google .gax .errors import GaxError
15201547
1521- self ._update_sink_called_with = sink_name , sink , options
1548+ self ._update_sink_called_with = (
1549+ sink_name , sink , unique_writer_identity , options )
15221550 if self ._random_gax_error :
15231551 raise GaxError ('error' )
15241552 try :
0 commit comments