File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -567,14 +567,26 @@ def topic_path(self):
567567 return 'projects/{}/topics/{}' .format (
568568 Config .CLIENT .project , self .TOPIC_NAME )
569569
570- def setUp (self ):
571- self .case_buckets_to_delete = []
570+ def _intialize_topic (self ):
572571 try :
573572 from google .cloud .pubsub_v1 import PublisherClient
574573 except ImportError :
575574 raise unittest .SkipTest ("Cannot import pubsub" )
576575 self .publisher_client = PublisherClient ()
577576 retry_429 (self .publisher_client .create_topic )(self .topic_path )
577+ policy = self .publisher_client .get_iam_policy (self .topic_path )
578+ binding = policy .bindings .add ()
579+ binding .role = 'roles/pubsub.publisher'
580+ binding .members .append (
581+ 'serviceAccount:{}'
582+ '@gs-project-accounts.iam.gserviceaccount.com' .format (
583+ Config .CLIENT .project ))
584+ self .publisher_client .set_iam_policy (self .topic_path , policy )
585+
586+
587+ def setUp (self ):
588+ self .case_buckets_to_delete = []
589+ self ._intialize_topic ()
578590
579591 def tearDown (self ):
580592 retry_429 (self .publisher_client .delete_topic )(self .topic_path )
You can’t perform that action at this time.
0 commit comments