
                         >   S r SSKJr  SSKJr  SSKJr  SSKJr  SSKrSSKrSSKrSSK	r	SSK
Jr  SSKJs  Jr  SSKJr  SS	KJr  SS
KJr  SSKJrJr  \" \" SSS5      5        SSKJr  S r\" 5       r " S S\R8                  5      r " S S\R<                  5      rg)+Integration tests for notification command.    )absolute_import)print_function)division)unicode_literalsN)CloudApiDelegator)ObjectToURI)unittest)Retry)add_moveMovedModulemockzunittest.mock)r   c                  B    [         R                  R                  SS5      $ )NGSUtiltest_notification_url)botoconfig	get_value     0platform/gsutil/gslib/tests/test_notification.py_LoadNotificationUrlr   (   s    			x)@	AAr   c                   V    \ rS rSr\R
                  R                  \SSS9S 5       rSr	g)TestNotificationUnit/   CreateNotificationConfigT)autospecc                     U R                  SS9nU R                  SSSSSSS	[        U5      /S
S9nUR                  [        R
                  S[        R
                  [        R
                  SS0S [        R
                  [        R
                  S9  g )Nfoo_notification)bucket_namenotificationcreatez-fnonez-sz-mzfoo:bar:bazT)return_stdoutfoozbar:baz)pubsub_topicpayload_formatcustom_attributesevent_typesobject_name_prefixprovider)CreateBucket
RunCommandsuriassert_called_once_withr   ANY)selfmock_create_notification
bucket_uristdouts       r   /test_notification_splits_dash_m_value_correctlyDTestNotificationUnit.test_notification_splits_dash_m_value_correctly1   s    
 ""/A"BJ__	4t]	j			  F
 44XXxx ),88 5 r   r   N)
__name__
__module____qualname____firstlineno__r   patchobjectr   r5   __static_attributes__r   r   r   r   r   /   s1    ::&/"  $$r   r   c                       \ rS rSrSr\R                  " \S5      S 5       r\R                  " \S5      S 5       r	\R                  " \S5      S 5       r
S rSrg	)
TestNotificationG   r   z-Test requires notification URL configuration.c                 ~   U R                  5       nU R                  SS[        [        U5      /5        [	        [
        R                  " 5       5      n[	        [
        R                  " 5       5      nU R                  SSSUSU[        [        U5      /SS9nU R                  SU-  U5        U R                  SU-  U5        g	)
z2Tests creating a notification channel on a bucket.r!   watchbucketz-iz-tTreturn_stderrz	token: %szidentifier: %sN)r,   	RunGsUtilNOTIFICATION_URLr.   struuiduuid4assertIn)r1   r3   
identifiertokenstderrs        r   test_watch_bucket"TestNotification.test_watch_bucketJ   s     ""$JNN	(8	j		 TZZ\"J

E^^tZuZ
 +/  0F 	MM+%v.MM"Z/8r   c                 j   U R                  5       nU R                  SS[        [        U5      /SS9n[        R
                  " SU5      nU R                  [        U5      S5        [        R
                  " SU5      nU R                  [        U5      S5        US   nUS   nU R                  SS	X4/5        g
)z2Tests stopping a notification channel on a bucket.r!   rB   TrC   zchannel identifier: (?P<id>.*)   zresource identifier: (?P<id>.*)r   stopchannelN)r,   rE   rF   r.   refindallassertEquallen)r1   r3   rM   
channel_idresource_ids        r   test_stop_channel"TestNotification.test_stop_channel^   s     ""$J^^	(8	j		  F
 =vFJS_a(**?HKS%q)AJa.KNNNM:KLr   c                 2   ^ ^ [         R                  " S5      $ )z/Tests listing notification channel on a bucket.z2Functionality has been disabled due to b/132277269)r
   skipr,   rE   rF   r.   r   AssertionErrortimesleeprS   rT   rU   rV   )	r1   _ListObjectChangeNotificationsrM   rW   rX   push_urlsubscriber_emailcreation_timer3   s	   `       @r   test_list_one_channel&TestNotification.test_list_one_channelr   s    
 ==MNNr   c                 N    U R                  / SQSSS9nU R                  SU5        g )N)r!   r%   barbazTrQ   )rD   expected_statuszInvalid subcommand)rE   rJ   )r1   rM   s     r   test_invalid_subcommand(TestNotification.test_invalid_subcommand   s/    ^^A*.,-  /F 	MM&/r   r   N)r7   r8   r9   r:   __doc__r
   
skipUnlessrF   rN   rY   rd   rj   r=   r   r   r   r?   r?   G   s    3'FH9H9$ 'FHMHM$ 'FH%,H%,N0r   r?   ) rl   
__future__r   r   r   r   rS   r^   rH   r   gslib.cloud_api_delegatorr   gslib.tests.testcaseteststestcasegslib.tests.utilr	   r.   r
   gslib.utils.retry_utilr   sixr   r   	six.movesr   r   rF   GsUtilUnitTestCaser   GsUtilIntegrationTestCaser?   r   r   r   <module>ry      s    2 & %  ' 	    7 ' ' 0 % ( % VV_	5 6 B () 866 0X0x99 X0r   