@@ -619,6 +619,7 @@ class Test_SinksAPI(_Base, unittest.TestCase):
619619 SINK_NAME = 'sink_name'
620620 SINK_PATH = 'projects/%s/sinks/%s' % (_Base .PROJECT , SINK_NAME )
621621 DESTINATION_URI = 'faux.googleapis.com/destination'
622+ SINK_WRITER_IDENTITY = 'serviceAccount:[email protected] ' 622623
623624 @staticmethod
624625 def _get_target_class ():
@@ -719,6 +720,7 @@ def test_sink_create_error(self):
719720
720721 def test_sink_create_conflict (self ):
721722 from google .cloud .exceptions import Conflict
723+ from google .cloud .proto .logging .v2 .logging_config_pb2 import LogSink
722724
723725 gax_api = _GAXSinksAPI (_create_sink_conflict = True )
724726 api = self ._make_one (gax_api , None )
@@ -728,16 +730,7 @@ def test_sink_create_conflict(self):
728730 self .PROJECT , self .SINK_NAME , self .FILTER ,
729731 self .DESTINATION_URI )
730732
731- def test_sink_create_ok (self ):
732- from google .cloud .proto .logging .v2 .logging_config_pb2 import LogSink
733-
734- gax_api = _GAXSinksAPI ()
735- api = self ._make_one (gax_api , None )
736-
737- api .sink_create (
738- self .PROJECT , self .SINK_NAME , self .FILTER , self .DESTINATION_URI )
739-
740- parent , sink , options , unique_writer_identity = (
733+ parent , sink , unique_writer_identity , options = (
741734 gax_api ._create_sink_called_with )
742735 self .assertEqual (parent , self .PROJECT_PATH )
743736 self .assertIsInstance (sink , LogSink )
@@ -747,24 +740,36 @@ def test_sink_create_ok(self):
747740 self .assertIsNone (options )
748741 self .assertFalse (unique_writer_identity )
749742
750- def test_sink_create_with_unique_writer_identity (self ):
743+ def test_sink_create_ok (self ):
751744 from google .cloud .proto .logging .v2 .logging_config_pb2 import LogSink
752745
753746 gax_api = _GAXSinksAPI ()
754747 api = self ._make_one (gax_api , None )
755- api .sink_create (
756- self .PROJECT , self .SINK_NAME , self .FILTER , self .DESTINATION_URI ,
748+
749+ returned = api .sink_create (
750+ self .PROJECT ,
751+ self .SINK_NAME ,
752+ self .FILTER ,
753+ self .DESTINATION_URI ,
757754 unique_writer_identity = True ,
758755 )
759- parent , sink , options , unique_writer_identity = (
756+
757+ self .assertEqual (returned , {
758+ 'name' : self .SINK_NAME ,
759+ 'filter' : self .FILTER ,
760+ 'destination' : self .DESTINATION_URI ,
761+ 'writerIdentity' : self .SINK_WRITER_IDENTITY ,
762+ })
763+
764+ parent , sink , unique_writer_identity , options = (
760765 gax_api ._create_sink_called_with )
761766 self .assertEqual (parent , self .PROJECT_PATH )
762767 self .assertIsInstance (sink , LogSink )
763768 self .assertEqual (sink .name , self .SINK_NAME )
764769 self .assertEqual (sink .filter , self .FILTER )
765770 self .assertEqual (sink .destination , self .DESTINATION_URI )
766- self .assertIsNone (options )
767771 self .assertTrue (unique_writer_identity )
772+ self .assertIsNone (options )
768773
769774 def test_sink_get_error (self ):
770775 from google .cloud .exceptions import NotFound
@@ -1482,14 +1487,22 @@ def list_sinks(self, parent, page_size, options):
14821487 self ._list_sinks_called_with = parent , page_size , options
14831488 return self ._list_sinks_response
14841489
1485- def create_sink (self , parent , sink , options , unique_writer_identity = False ):
1490+ def create_sink (self , parent , sink , unique_writer_identity , options ):
14861491 from google .gax .errors import GaxError
1492+ from google .cloud .proto .logging .v2 .logging_config_pb2 import LogSink
14871493
1488- self ._create_sink_called_with = parent , sink , options , unique_writer_identity
1494+ self ._create_sink_called_with = (
1495+ parent , sink , unique_writer_identity , options )
14891496 if self ._random_gax_error :
14901497 raise GaxError ('error' )
14911498 if self ._create_sink_conflict :
14921499 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+ )
14931506
14941507 def get_sink (self , sink_name , options ):
14951508 from google .gax .errors import GaxError
0 commit comments