
    3                         S r SSKJr  SSKJr  SSKJr  SSKJr   " S S\5      r " S S	\5      r	 " S
 S\5      r
 " S S\5      rg)z6Helper functions for testing calls to the Rewrite API.    )absolute_import)print_function)division)unicode_literalsc                       \ rS rSrSrg)RewriteHaltException    N)__name__
__module____qualname____firstlineno____static_attributes__r
       -platform/gsutil/gslib/tests/rewrite_helper.pyr   r      s    r   r   c                   $    \ rS rSrSrS rS rSrg)HaltingRewriteCallbackHandler   zETest callback handler for intentionally stopping a rewrite operation.c                     Xl         g N_halt_at_byte)selfhalt_at_bytes     r   __init__&HaltingRewriteCallbackHandler.__init__   s    %r   c                 8    XR                   :  a  [        S5      eg)z=Forcibly exits if the operation has passed the halting point.zArtificially halting rewriteN)r   r   r   total_bytes_rewrittenunused_total_sizes      r   call"HaltingRewriteCallbackHandler.call"   s     2 22 !?@@ 3r   r   Nr   r   r   r   __doc__r   r!   r   r
   r   r   r   r      s    M&Ar   r   c                   $    \ rS rSrSrS rS rSrg)"EnsureRewriteResumeCallbackHandler(   z?Test callback handler for ensuring a rewrite operation resumed.c                     Xl         g r   _required_byter   required_bytes     r   r   +EnsureRewriteResumeCallbackHandler.__init__+   s    'r   c                 ^    XR                   ::  a  [        SU< SU R                   < S35      eg)z9Exits if the total bytes rewritten is less than expected.zRewrite did not resume; z bytes written, but ( bytes should have already been written.N)r*   r   r   s      r   r!   'EnsureRewriteResumeCallbackHandler.call/   s2     3 33  !$"5"578 8 4r   r)   Nr#   r
   r   r   r&   r&   (   s    G(8r   r&   c                   $    \ rS rSrSrS rS rSrg)#EnsureRewriteRestartCallbackHandler8   zATest callback handler for ensuring a rewrite operation restarted.c                     Xl         SU l        g )NF)r*   _got_restart_bytesr+   s     r   r   ,EnsureRewriteRestartCallbackHandler.__init__;   s    '#Dr   c                     U R                   (       d5  XR                  ::  a  SU l         g[        SU< SU R                  < S35      eg)z<Exits if the total bytes rewritten is greater than expected.TzRewrite did not restart; z! bytes written, but no more than r/   N)r5   r*   r   r   s      r   r!   (EnsureRewriteRestartCallbackHandler.call@   sE    ""	"5"5	5 #'" #D$7$79: 	: #r   )r5   r*   Nr#   r
   r   r   r2   r2   8   s    I$
:r   r2   N)r$   
__future__r   r   r   r   	Exceptionr   objectr   r&   r2   r
   r   r   <module>r<      sH    = & %  '9 
AF 
A8 8 :& :r   