
|W>                 @   sN  d  d l  Z d  d l j j Z d  d l Z d  d l Z d  d l m	 Z	 d  d l
 Z
 d  d l Z e j j j d  Z d d   Z d d   Z Gd d	   d	 e  Z Gd
 d   d e j j  Z Gd d   d e  Z Gd d   d e j j  Z Gd d   d e  Z d d   Z Gd d   d  Z Gd d   d  Z Gd d   d  Z d S)    N)SvnAuthsvnc             C   s   t  j j |   j d  } | j d  j d  d } d } xF | D]> } | d | | | d f 7} | d | | | d f 7} qD W| j d	  j |  | j d
  j |  d S)z write config to repo

        user information in userdata is used for auth
        userdata has user names as keys, and a tuple (password, readwrite) as
        values, where 'readwrite' is either 'r' or 'rw'
    Zconfzsvnserve.confzT[general]
anon-access = none
password-db = passwd
authz-db = authz
realm = TestRepo
z[/]
z[users]
z%s = %s
   r   ZauthzpasswdN)pypathlocaljoinwrite)repoZuserdataZconfdirZ	authzdataZ
passwddatauser r   ?/home/ronny/Projects/pytest-dev/py/testing/path/test_svnauth.pymake_repo_auth	   s     r   c             C   s0  t  j j |   j d  } d } d  } x | d k  rd | | |  f } t |  y t  j j |  Wn+ t  j j j k
 r t j	   d } Ynw Xd } } xY | d k  r | d 7} y | j
   } Wn t  j j k
 r Yn X| r Pt j d  q W| t |  f S| d 7} q* Wt d	 | f   d  S)
Npidi'  i'  z3svnserve -d -T --listen-port=%d --pid-file=%s -r %sr   r   
   g?zcould not start svnserve: %s)r   r   r   r	   printprocesscmdexecErrorsysexc_inforeaderrorENOENTtimesleepintIOError)repopathZpidfileportecmdcounterr   r   r   r   serve_bg    s0    


r$   c               @   sX   e  Z d  Z d d   Z d d   Z d d   Z d d   Z d	 d
   Z d d   Z d S)TestSvnAuthc       	      C   sc  t  d d  } | j } d } | | k } | s t j d | f d | | f  d d t j   k sr t j |  r t j |  n d d t j |  d t j |  i } d d | i } t t j	 |    d  } } } | j
 } d } | | k } | st j d | f d | | f  d d t j   k s?t j |  rNt j |  n d d t j |  d t j |  i } d d | i } t t j	 |    d  } } } t |  } | sYd	 d d d t j   k st j |  rt j |  n d d d t j   k st j t  r+t j t  n d d t j |  i } t t j	 |    d  } d  S)Nfoobar==0%(py2)s
{%(py2)s = %(py0)s.username
} == %(py5)spy0authpy5py2 assert %(py7)spy70%(py2)s
{%(py2)s = %(py0)s.password
} == %(py5)sz,assert %(py3)s
{%(py3)s = %(py0)s(%(py1)s)
}py1strpy3)r(   )r)   r/   )r(   )r1   r/   )r   username
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_safereprAssertionError_format_explanationpasswordr3   )	selfr+   @py_assert1@py_assert4@py_assert3@py_format6@py_format8@py_assert2@py_format4r   r   r   
test_basic>   s,    	    y   	    y       zTestSvnAuth.test_basicc          
   C   s   t  d d  } | j } |   } d } | | k } | s t j d | f d | | f  d t j |  d d t j   k s t j |  r t j |  n d d	 t j |  d
 t j |  i } d d | i } t t j	 |    d  } } } } d  S)Nr&   r'   z!--username="foo" --password="bar"r(   M%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.makecmdoptions
}()
} == %(py7)sr0   r*   r+   r-   py4r.   assert %(py9)spy9)r(   )rH   rJ   )
r   makecmdoptionsr6   r7   r;   r8   r9   r:   r<   r=   )r?   r+   r@   rB   @py_assert6@py_assert5rD   @py_format10r   r   r   $test_makecmdoptions_uname_pw_makestrD   s    	 	       z0TestSvnAuth.test_makecmdoptions_uname_pw_makestrc          
   C   s   t  d d  } | j } |   } d } | | k } | s t j d | f d | | f  d t j |  d d t j   k s t j |  r t j |  n d d	 t j |  d
 t j |  i } d d | i } t t j	 |    d  } } } } d  S)Nzfo"oz"ba'r"z(--username="fo\"o" --password="\"ba'r\""r(   M%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.makecmdoptions
}()
} == %(py7)sr0   r*   r+   r-   rI   r.   assert %(py9)srK   )r(   )rQ   rR   )
r   rL   r6   r7   r;   r8   r9   r:   r<   r=   )r?   r+   r@   rB   rM   rN   rD   rO   r   r   r    test_makecmdoptions_quote_escapeH   s    	 	       z,TestSvnAuth.test_makecmdoptions_quote_escapec          
   C   s  t  d d d d } | j } |   } d } | | k } | s t j d | f d | | f  d t j |  d	 d
 t j   k s t j |  r t j |  n d
 d t j |  d t j |  i } d d | i } t t j	 |    d  } } } } d  S)Nr&   r'   
cache_authFz1--username="foo" --password="bar" --no-auth-cacher(   M%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.makecmdoptions
}()
} == %(py7)sr0   r*   r+   r-   rI   r.   assert %(py9)srK   )r(   )rU   rV   )
r   rL   r6   r7   r;   r8   r9   r:   r<   r=   )r?   r+   r@   rB   rM   rN   rD   rO   r   r   r   !test_makecmdoptions_no_cache_authL   s    	 	       z-TestSvnAuth.test_makecmdoptions_no_cache_authc          
   C   s  t  d d d d } | j } |   } d } | | k } | s t j d | f d | | f  d t j |  d	 d
 t j   k s t j |  r t j |  n d
 d t j |  d t j |  i } d d | i } t t j	 |    d  } } } } d  S)Nr&   r'   interactiveFz3--username="foo" --password="bar" --non-interactiver(   M%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.makecmdoptions
}()
} == %(py7)sr0   r*   r+   r-   rI   r.   assert %(py9)srK   )r(   )rY   rZ   )
r   rL   r6   r7   r;   r8   r9   r:   r<   r=   )r?   r+   r@   rB   rM   rN   rD   rO   r   r   r   "test_makecmdoptions_no_interactiveQ   s    	 	       z.TestSvnAuth.test_makecmdoptions_no_interactivec          
   C   s  t  d d d d d d } | j } |   } d } | | k } | s t j d | f d | | f  d	 t j |  d
 d t j   k s t j |  r t j |  n d d t j |  d t j |  i } d d | i } t t j	 |    d  } } } } d  S)Nr&   r'   rT   FrX   zC--username="foo" --password="bar" --no-auth-cache --non-interactiver(   M%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.makecmdoptions
}()
} == %(py7)sr0   r*   r+   r-   rI   r.   assert %(py9)srK   )r(   )r\   r]   )
r   rL   r6   r7   r;   r8   r9   r:   r<   r=   )r?   r+   r@   rB   rM   rN   rD   rO   r   r   r   0test_makecmdoptions_no_interactive_no_cache_authV   s    		 	       z<TestSvnAuth.test_makecmdoptions_no_interactive_no_cache_authN)	__name__
__module____qualname__rG   rP   rS   rW   r[   r^   r   r   r   r   r%   =   s   r%   c                   s.   e  Z d  Z   f d d   Z d d   Z   S)svnwc_no_svnc                s+   t  t |   j |  | |  } g  | _ | S)N)superrb   __new__commands)clsargskwargsr?   )	__class__r   r   rd   ]   s    	zsvnwc_no_svn.__new__c             G   s   |  j  j |  d  S)N)re   append)r?   rg   r   r   r   _svnb   s    zsvnwc_no_svn._svn)r_   r`   ra   rd   rk   r   r   )ri   r   rb   \   s   rb   c               @   sL   e  Z d  Z d d   Z d d   Z d d   Z d d   Z d	 d
   Z d S)TestSvnWCAuthc             C   s2   t  s t j j d  t d d d d |  _ d  S)Nzsvn binary requiredr   passrT   F)svnbinr   testskipr   r+   )r?   methr   r   r   setup_methodf   s    zTestSvnWCAuth.setup_methodc             C   s   t  d d |  j } | j d  | j d d } d } | | k } | s t j d | f d | | f  d	 t j |  d
 t j |  i } d d | i } t t j |    d  } } } d  S)Nr&   r+   urlr   r   z3--username="user" --password="pass" --no-auth-cacher(   %(py1)s == %(py4)sr2   rI   r.   assert %(py6)spy6)r(   )rt   ru   )	rb   r+   checkoutre   r6   r7   r;   r<   r=   )r?   wc@py_assert0rB   rE   @py_format5@py_format7r   r   r   test_checkoutk   s        C   zTestSvnWCAuth.test_checkoutc             C   s   t  d d |  j } | j d  | j d d } d } | | k } | s t j d | f d | | f  d	 t j |  d
 t j |  i } d d | i } t t j |    d  } } } d  S)Nr&   r+   msgr   r   z3--username="user" --password="pass" --no-auth-cacher(   %(py1)s == %(py4)sr2   rI   r.   assert %(py6)srv   rw   )r(   )r   r   )	rb   r+   commitre   r6   r7   r;   r<   r=   )r?   ry   rz   rB   rE   r{   r|   r   r   r   test_commitq   s        C   zTestSvnWCAuth.test_commitc             C   s   t  d d |  j } | j d  | j d d } d } | | k } | s t j d | f d | | f  d	 t j |  d
 t j |  i } d d | i } t t j |    d  } } } d  S)Nr&   r+   rs   r   r   z3--username="user" --password="pass" --no-auth-cacher(   %(py1)s == %(py4)sr2   rI   r.   assert %(py6)srv   rw   )r(   )r   r   )	rb   r+   rx   re   r6   r7   r;   r<   r=   )r?   ry   rz   rB   rE   r{   r|   r   r   r   test_checkout_no_cache_authw   s        C   z)TestSvnWCAuth.test_checkout_no_cache_authc             C   s   t  d d |  j } | j d  | j d d } d } | | k } | s t j d | f d | | f  d	 t j |  d
 t j |  i } d d | i } t t j |    d  } } } d  S)Nr&   r+   rs   r   r   z3--username="user" --password="pass" --no-auth-cacher(   %(py1)s == %(py4)sr2   rI   r.   assert %(py6)srv   rw   )r(   )r   r   )	rb   r+   rx   re   r6   r7   r;   r<   r=   )r?   ry   rz   rB   rE   r{   r|   r   r   r   #test_checkout_auth_from_constructor}   s        C   z1TestSvnWCAuth.test_checkout_auth_from_constructorN)r_   r`   ra   rr   r}   r   r   r   r   r   r   r   rl   e   s
   rl   c                   sF   e  Z d  Z d Z d Z   f d d   Z d d   Z d d   Z   S)svnurl_no_svnro   c                s+   t  t |   j |  | |  } g  | _ | S)N)rc   r   rd   re   )rf   rg   rh   r?   )ri   r   r   rd      s    	zsvnurl_no_svn.__new__c             C   s   |  j  j |  |  j S)N)re   rj   cmdexec_output)r?   r"   r   r   r   _cmdexec   s    zsvnurl_no_svn._cmdexecc             C   s   |  j  j |  |  j S)N)re   rj   popen_output)r?   r"   r   r   r   _popen   s    zsvnurl_no_svn._popen)r_   r`   ra   r   r   rd   r   r   r   r   )ri   r   r      s
   r   c               @   s   e  Z d  Z d d   Z d d   Z d d   Z d d   Z d	 d
   Z d d   Z d d   Z	 d d   Z
 d d   Z d d   Z d d   Z d d   Z d d   Z d d   Z d d   Z d S) TestSvnURLAuthc             C   s   t  d d  |  _ d  S)Nr&   r'   )r   r+   )r?   rq   r   r   r   rr      s    zTestSvnURLAuth.setup_methodc       
   
   C   s  t  d  } | j } d  } | | k } | s t j d | f d | | f  d d t j   k so t j |  r~ t j |  n d d t j |  d t j |  i } d d
 | i } t t j	 |    d  } } } t  d d |  j } | j } |  j } | | k } | st j d | f d | | f  d t j |  d d t j   k sct j |  rrt j |  n d d t j |  d d t j   k st j |   rt j |   n d i } d d | i }	 t t j	 |	    d  } } } d  S)Nzhttp://foo.bar/svnis,%(py2)s
{%(py2)s = %(py0)s.auth
} is %(py5)sr*   ur,   r-   r.   assert %(py7)sr0   r+   F%(py2)s
{%(py2)s = %(py0)s.auth
} is %(py6)s
{%(py6)s = %(py4)s.auth
}rv   rI   r?   assert %(py8)spy8)r   )r   r   )r   )r   r   )
r   r+   r6   r7   r8   r9   r:   r;   r<   r=   )
r?   r   r@   rA   rB   rC   rD   rN   r|   @py_format9r   r   r   	test_init   s$    	    y   	 	      zTestSvnURLAuth.test_initc          
   C   s  t  d d |  j } | j d d  } | j } |  j } | | k } | st j d | f d | | f  d t j |  d d	 t j   k s t j |  r t j |  n d	 d
 t j |  d d t j   k s t j |   r t j |   n d i } d d | i } t	 t j
 |    d  } } } | j } d } | | k } | st j d | f d | | f  d d	 t j   k st j |  rt j |  n d	 d t j |  d
 t j |  i }	 d d |	 i }
 t	 t j
 |
    d  } } } d  S)Nzhttp://foo.bar/svn/foor+   basenamer'   r   F%(py2)s
{%(py2)s = %(py0)s.auth
} is %(py6)s
{%(py6)s = %(py4)s.auth
}rv   r*   newr-   rI   r?   r.   assert %(py8)sr   zhttp://foo.bar/svn/barr(   +%(py2)s
{%(py2)s = %(py0)s.url
} == %(py5)sr,   assert %(py7)sr0   )r   )r   r   )r(   )r   r   )r   r+   r   r6   r7   r;   r8   r9   r:   r<   r=   rs   )r?   r   r   r@   rN   rB   r|   r   rA   rC   rD   r   r   r   test_new   s$    	 	      	    y   zTestSvnURLAuth.test_newc          
   C   s  t  d d |  j } | j d  } | j } |  j } | | k } | st j d | f d | | f  d t j |  d d t j   k s t j |  r t j |  n d d	 t j |  d
 d t j   k s t j |   r t j |   n d i } d d | i } t	 t j
 |    d  } } } | j } d } | | k } | st j d | f d | | f  d d t j   k st j |  rt j |  n d d t j |  d	 t j |  i }	 d d |	 i }
 t	 t j
 |
    d  } } } d  S)Nzhttp://foo.bar/svnr+   r&   r   F%(py2)s
{%(py2)s = %(py0)s.auth
} is %(py6)s
{%(py6)s = %(py4)s.auth
}rv   r*   r   r-   rI   r?   r.   assert %(py8)sr   zhttp://foo.bar/svn/foor(   +%(py2)s
{%(py2)s = %(py0)s.url
} == %(py5)sr,   assert %(py7)sr0   )r   )r   r   )r(   )r   r   )r   r+   r	   r6   r7   r;   r8   r9   r:   r<   r=   rs   )r?   r   r   r@   rN   rB   r|   r   rA   rC   rD   r   r   r   	test_join   s$    	 	      	    y   zTestSvnURLAuth.test_joinc          
   C   s  t  d d |  j } d | _ | j   } | d } | j } |  j } | | k } | st j d | f d | | f  d t j |  d d	 t j   k s t j	 |   r t j |   n d	 d
 t j |  d t j |  i } d d | i } t
 t j |    d  } } } } | d } | j } |  j } | | k } | st j d | f d | | f  d t j |  d d	 t j   k st j	 |   rt j |   n d	 d
 t j |  d t j |  i } d d | i } t
 t j |    d  } } } } | d } | j } d }	 | |	 k } | st j d | f d | |	 f  d t j |	  d
 t j |  d t j |  i }
 d d |
 i } t
 t j |    d  } } } }	 d  S)Nzhttp://foo.bar/svnr+   zm   1717 johnny           1529 Nov 04 14:32 LICENSE.txt
   1716 johnny           5352 Nov 04 14:28 README.txt
r   r   F%(py3)s
{%(py3)s = %(py1)s.auth
} is %(py7)s
{%(py7)s = %(py5)s.auth
}r0   r,   r?   r2   r4   r.   assert %(py9)srK   r   zLICENSE.txtr(   0%(py3)s
{%(py3)s = %(py1)s.basename
} == %(py6)srv   assert %(py8)sr   )r   )r   r   )r   )r   r   )r(   )r   r   )r   r+   r   listdirr6   r7   r;   r8   r9   r:   r<   r=   r   )r?   r   pathsrz   rE   rM   rA   rD   rO   rN   r|   r   r   r   r   test_listdir   s<    	
 	 	      
 	 	      
 	    R   zTestSvnURLAuth.test_listdirc       
      C   s0  t  d d |  j } d d   } d | _ | j j } | | j _ z | j   } Wd  | | _ X| j } d } | | k } | st j d | f d | | f  d	 d
 t	 j
   k s t j |  r t j |  n d
 d t j |  d t j |  i } d d | i }	 t t j |	    d  } } } d  S)Nzhttp://foo.bar/svn/LICENSE.txtr+   c             S   s   |  S)Nr   )r?   r   r   r   dirpath   s    z)TestSvnURLAuth.test_info.<locals>.dirpathzm   1717 johnny           1529 Nov 04 14:32 LICENSE.txt
   1716 johnny           5352 Nov 04 14:28 README.txt
i  r(   ,%(py2)s
{%(py2)s = %(py0)s.size
} == %(py5)sr*   infor,   r-   r.   assert %(py7)sr0   )r(   )r   r   )r   r+   r   ri   r   r   sizer6   r7   r8   r9   r:   r;   r<   r=   )
r?   r   r   Zorg_dpr   r@   rA   rB   rC   rD   r   r   r   	test_info   s     	
	    y   zTestSvnURLAuth.test_infoc             C   s  t  d d |  j } | j d  } d d   | _ | j   } d } | | k } | s t j d | f d | | f  d	 d
 t j   k s t j	 |  r t j
 |  n d
 d t j
 |  i } d d | i } t t j |    d  } } d } | j d }	 | |	 k } | s}t j d | f d | |	 f  d t j
 |  d t j
 |	  i }
 d d |
 i } t t j |    d  } } }	 d  S)Nzhttp://foo.bar/svnr+   r&   c              _   s   d S)NTr   )rg   rh   r   r   r   <lambda>   s    z*TestSvnURLAuth.test_open.<locals>.<lambda>ro   r(   %(py0)s == %(py3)sr*   retr4   r.   assert %(py5)sr,   z!--username="foo" --password="bar"r   in%(py1)s in %(py4)sr2   rI   assert %(py6)srv   )r(   )r   r   )r   )r   r   )r   r+   r	   checkopenr6   r7   r8   r9   r:   r;   r<   r=   re   )r?   r   r&   r   rE   r@   rF   rC   rz   rB   r{   r|   r   r   r   	test_open   s&       j   
    C   zTestSvnURLAuth.test_openc          
   C   s+  t  d d |  j } | j   } | j } |  j } | | k } | st j d | f d | | f  d t j |  d d t j   k s t j |  r t j |  n d d t j |  d	 d
 t j   k s t j |   r t j |   n d
 i } d d | i } t	 t j
 |    d  } } } d  S)Nzhttp://foo.bar/svn/foor+   r   F%(py2)s
{%(py2)s = %(py0)s.auth
} is %(py6)s
{%(py6)s = %(py4)s.auth
}rv   r*   parentr-   rI   r?   r.   assert %(py8)sr   )r   )r   r   )r   r+   r   r6   r7   r;   r8   r9   r:   r<   r=   )r?   r   r   r@   rN   rB   r|   r   r   r   r   test_dirpath   s    	 	      zTestSvnURLAuth.test_dirpathc       
      C   s  t  d d |  j } | j } | } | s d d d d t j   k sV t j |  re t j |  n d d t j |  i } t t j	 |    d  } } | j
 d d	  | j } | s$d d
 d d t j   k s t j |  r t j |  n d d t j |  i } t t j	 |    d  } d } | j d } | | k } | st j d | f d | | f  d t j |  d t j |  i } d d | i }	 t t j	 |	    d  } } } d  S)Nzhttp://foo.bar/svn/qweqwer+   r.   z0assert not %(py2)s
{%(py2)s = %(py0)s.commands
}r*   r   r-   r~   zcreated dir fooz,assert %(py2)s
{%(py2)s = %(py0)s.commands
}z!--username="foo" --password="bar"r   r   %(py1)s in %(py4)sr2   rI   assert %(py6)srv   )r   )r   r   )r   r+   re   r8   r9   r6   r:   r;   r<   r=   mkdirr7   )
r?   r   r@   rB   rF   @py_format3rz   rE   r{   r|   r   r   r   
test_mkdir   s*    	   S  
	  S      C   zTestSvnURLAuth.test_mkdirc             C   s   t  d d |  j } t  d  } | j | d  d } | j d } | | k } | s t j d | f d | | f  d	 t j |  d
 t j |  i } d d | i } t t j |    d  } } } d  S)Nzhttp://foo.bar/svnr+   zhttp://foo.bar/svn2z
copied dirz!--username="foo" --password="bar"r   r   %(py1)s in %(py4)sr2   rI   r.   assert %(py6)srv   )r   )r   r   )	r   r+   copyre   r6   r7   r;   r<   r=   )r?   r   u2rz   rB   rE   r{   r|   r   r   r   	test_copy   s        C   zTestSvnURLAuth.test_copyc             C   s   t  d d |  j } | j d d  d } | j d } | | k } | s t j d | f d | | f  d	 t j |  d
 t j |  i } d d | i } t t j |    d  } } } d  S)Nzhttp://foo.bar/svn/foor+   zhttp://foo.bar/svn/barzmoved foo to barz!--username="foo" --password="bar"r   r   %(py1)s in %(py4)sr2   rI   r.   assert %(py6)srv   )r   )r   r   )	r   r+   renamere   r6   r7   r;   r<   r=   )r?   r   rz   rB   rE   r{   r|   r   r   r   test_rename   s        C   zTestSvnURLAuth.test_renamec             C   s   t  d d |  j } | j d d  d } | j d } | | k } | s t j d | f d | | f  d	 t j |  d
 t j |  i } d d | i } t t j |    d  } } } d  S)Nzhttp://foo.bar/svn/foor+   r~   zremoving fooz!--username="foo" --password="bar"r   r   %(py1)s in %(py4)sr2   rI   r.   assert %(py6)srv   )r   )r   r   )	r   r+   removere   r6   r7   r;   r<   r=   )r?   r   rz   rB   rE   r{   r|   r   r   r   test_remove   s        C   zTestSvnURLAuth.test_removec             C   s   t  d d |  j } t j j d  } | j |  d } | j d } | | k } | s t j d | f d | | f  d t j	 |  d	 t j	 |  i } d d | i } t
 t j |    d  } } } d  S)Nzhttp://foo.bar/svnr+   z/fooz!--username="foo" --password="bar"r   r   %(py1)s in %(py4)sr2   rI   r.   assert %(py6)srv   )r   )r   r   )r   r+   r   r   r   Zexportre   r6   r7   r;   r<   r=   )r?   r   targetrz   rB   rE   r{   r|   r   r   r   test_export   s        C   zTestSvnURLAuth.test_exportc             C   s  t  d d |  j } t j j t j j d d   | _ d d   | _ | j	 d d d	 d
 } d } | j
 d } | | k } | s t j d& | f d' | | f  d t j |  d t j |  i } d( d | i } t t j |    d  } } } t |  } d } | | k }	 |	 st j d) |	 f d* | | f  d d t j   k sat j |  rpt j |  n d d t j |  d d t j   k st j t  rt j t  n d d t j |  i } d+ d | i }
 t t j |
    d  } }	 } | d } | j } t |  } d } | | k } | st j d, | f d- | | f  d t j |  d t j |  d d  t j   k st j t  rt j t  n d  d! t j |  d t j |  i } d. d# | i } t t j |    d  } } } } } | d } | j } d$ } | | k }	 |	 st j d/ |	 f d0 | | f  d t j |  d t j |  d t j |  i } d1 d | i }
 t t j |
    d  } } }	 } d  S)2Nzhttp://foo.bar/svn/foor+   z<?xml version="1.0"?>
<log>
<logentry revision="51381">
<author>guido</author>
<date>2008-02-11T12:12:18.476481Z</date>
<msg>Creating branch to work on auth support for py.path.svn*.
</msg>
</logentry>
</log>
asciic              _   s   d S)NTr   )rg   rh   r   r   r   r      s    z)TestSvnURLAuth.test_log.<locals>.<lambda>r      verboseTz!--username="foo" --password="bar"r   r   %(py1)s in %(py4)sr2   rI   r.   assert %(py6)srv   r   r(   0%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py6)sr   r*   lenr4   assert %(py8)sr   i  I%(py6)s
{%(py6)s = %(py0)s(%(py4)s
{%(py4)s = %(py2)s.rev
})
} == %(py9)srK   r   r-   assert %(py11)spy11Zguido.%(py3)s
{%(py3)s = %(py1)s.author
} == %(py6)s)r   )r   r   )r(   )r   r   )r(   )r   r   )r(   )r   r   )r   r+   r   ioTextIObuiltin_totextr   r   logre   r6   r7   r;   r<   r=   r   r8   r9   r:   revr   author)r?   r   r   rz   rB   rE   r{   r|   rN   rA   r   r@   @py_assert8@py_assert7rO   @py_format12r   r   r   test_log   sP    
    C          
 	        
 	    R   zTestSvnURLAuth.test_logc             C   s   t  d d |  j } | j d  d } | j d } | | k } | s t j d | f d | | f  d t j |  d	 t j |  i } d d | i } t t j |    d  } } } d  S)Nzhttp://foo.bar/svnr+   r&   z!--username="foo" --password="bar"r   r   %(py1)s in %(py4)sr2   rI   r.   assert %(py6)srv   )r   )r   r   )	r   r+   propgetre   r6   r7   r;   r<   r=   )r?   r   rz   rB   rE   r{   r|   r   r   r   test_propget  s        C   zTestSvnURLAuth.test_propgetN)r_   r`   ra   rr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      s   r   c             C   s
   t  |   S)N)Setup)requestr   r   r   pytest_funcarg__setup  s    r   c               @   s   e  Z d  Z d d   Z d S)r   c                s  t  s t j j d  | j j j s5 t j j d  | j d  } | j d  } t j	 j
 d |  t j d k r d t |  j d d  } t j j d	 |    _ t j j j d k r | d
 d   } t j j |    _ | j d    _ t d d d d d d   _ t   j d d i  t   j j    \   _   _ t j j j j j    | j!   f d d    d  S)Nzsvn binary requiredz%use --runslowtests to run these teststmpdirr   zsvnadmin create %swin32/\z	file://%sr   temppathjohnnyr&   rT   FrX   rwc                  s   t  j j   j  S)N)r   r   killr   r   )r?   r   r   r   #  s    z Setup.__init__.<locals>.<lambda>)zfoozrw)"rn   r   ro   rp   configoptionrunslowtestsgetfuncargvaluer	   r   r   r   platformr3   replacer   svnurlr   stdr   r   r   r   r   r+   r   r$   r   r    r   _lsnorevcache_dictclearaddfinalizer)r?   r   r   Zrepodirr   )r?   r   __init__  s(    !zSetup.__init__N)r_   r`   ra   r  r   r   r   r   r     s   r   c               @   sp   e  Z d  Z d d   Z d d   Z d d   Z d d   Z d	 d
   Z d d   Z d d   Z	 d d   Z
 d S)TestSvnWCAuthFunctionalc       	      C   s/  t  j j | j d | j } | j d | j | j j f  | j	 } d } | |  } | j
 } |   } | sd d d t j |  d d t j   k s t j |  r t j |  n d d	 t j |  d
 t j |  d t j |  d t j |  i } t t j |    d  } } } } } d  S)Nr+   zsvn://localhost:%s/%sz.svnr.   zzassert %(py10)s
{%(py10)s = %(py8)s
{%(py8)s = %(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.join
}(%(py4)s)
}.check
}()
}rv   r*   ry   r-   rI   py10r   )r   r   svnwcr   r+   rx   r    r   r   r	   r   r6   r;   r8   r9   r:   r<   r=   )	r?   setupry   r@   rB   rN   r   @py_assert9@py_format11r   r   r   test_checkout_constructor_arg&  s    	   	 	    z5TestSvnWCAuthFunctional.test_checkout_constructor_argc       	      C   s/  t  j j | j d | j } | j d | j | j j f  | j	 } d } | |  } | j
 } |   } | sd d d t j |  d d t j   k s t j |  r t j |  n d d	 t j |  d
 t j |  d t j |  d t j |  i } t t j |    d  } } } } } d  S)Nr+   zsvn://localhost:%s/%sz.svnr.   zzassert %(py10)s
{%(py10)s = %(py8)s
{%(py8)s = %(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.join
}(%(py4)s)
}.check
}()
}rv   r*   ry   r-   rI   r	  r   )r   r   r
  r   r+   rx   r    r   r   r	   r   r6   r;   r8   r9   r:   r<   r=   )	r?   r  ry   r@   rB   rN   r   r  r  r   r   r   test_checkout_function_arg,  s    	   	 	    z2TestSvnWCAuthFunctional.test_checkout_function_argc             C   sQ   t  d d d d d d } t j j | j |  } t j j t d | j  d  S)Nr   r'   rT   FrX   z4wc.checkout('svn://localhost:%(port)s/%(repopath)s'))	r   r   r   r
  r   ro   raises	Exception__dict__)r?   r  r+   ry   r   r   r   %test_checkout_failing_non_interactive2  s    	z=TestSvnWCAuthFunctional.test_checkout_failing_non_interactivec          
   C   s!  t  j j | j | j  } | j d | j | j j f  | j	 d  } | j
 d  | j   } t |  } d } | | k } | s[t j d | f d | | f  d d t j   k s t j |  r t j |  n d d	 t j |  d
 d t j   k st j t  rt j t  n d d t j |  i } d d | i }	 t t j |	    d  } } } | d }
 |
 j } d } | | k } | st j d | f d | | f  d	 t j |  d t j |
  d t j |  i } d d | i }	 t t j |	    d  }
 } } } d  S)Nzsvn://localhost:%s/%szfoo.txtzadded foo.txtr   r(   0%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py6)sr2   r   rv   r*   r   r4   r.   assert %(py8)sr   r   +%(py3)s
{%(py3)s = %(py1)s.msg
} == %(py6)s)r(   )r  r  )r(   )r  r  )r   r   r
  r   r+   rx   r    r   r   ensurer   r   r   r6   r7   r8   r9   r:   r;   r<   r=   r~   )r?   r  ry   r&   r   rE   rN   rA   r|   r   rz   r   r   r   r   :  s.           
 	    R   z TestSvnWCAuthFunctional.test_logc       	   
   C   so  t  j j | j d | j } d | j | j j f } | j |  | j	 d d d j	 d  j
 d  | j d  | j	 d d d | j d	  | j d  } | j | d
  | j } d } | |  } | s]d d d t j |  d d t j   k st j |  r t j |  n d d t j |  d t j |  i } t t j |    d  } } } d  S)Nr+   zsvn://localhost:%s/%sr&   dirTzfoo.txtzadded foo dir with foo.txt filer'   zadded bar dirz/foor.   zFassert %(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.join
}(%(py4)s)
}rv   r*   r-   rI   )r   r   r
  r   r+   r    r   r   rx   r  r
   r   r	   switchr6   r;   r8   r9   r:   r<   r=   )	r?   r  ry   r  r'   r@   rB   rN   r|   r   r   r   test_switchD  s     %	    q  z#TestSvnWCAuthFunctional.test_switchc             C   s  t  j j | j j d d d d | j } t  j j | j j d d d d | j } | j d | j | j j	 f  | j d | j | j j	 f  | j d d d | j
 d  | j   | j } d } | |  } | j } |   } | sd	 d
 d t j |  d d t j   k s1t j |  r@t j |  n d d t j |  d t j |  d t j |  d t j |  i }	 t t j |	    d  } } } } } t d d d d }
 |
 | _ t  j j t d  d  S)Nwc1r  Tr+   wc2zsvn://localhost:%s/%sr&   zadded foo dirr.   zzassert %(py10)s
{%(py10)s = %(py8)s
{%(py8)s = %(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.join
}(%(py4)s)
}.check
}()
}rv   r*   r-   rI   r	  r   unknownrX   Fzwc2.update())r   r   r
  r   r  r+   rx   r    r   r   r   updater	   r   r6   r;   r8   r9   r:   r<   r=   r   ro   r  r  )r?   r  r  r  r@   rB   rN   r   r  r  r+   r   r   r   test_updateP  s.    !!
	   	 	    	z#TestSvnWCAuthFunctional.test_updatec             C   s  | j  } t j j | j d | j } | j d | | j j f  | j	 d d d | j
 d  | j d  } | j   | j   } | j } | s d d d	 d
 t j   k s t j |  r t j |  n d
 d t j |  i } t t j |    d  } | j   | j   } | j } | } | sd d d	 d
 t j   k s]t j |  rlt j |  n d
 d t j |  i }	 t t j |	    d  } } t d d d d }
 |
 | _ t j j t d  t j j t d  d  S)Nr+   zsvn://localhost:%s/%sr&   fileTzadded foo filer.   z*assert %(py2)s
{%(py2)s = %(py0)s.locked
}r*   statusr-   z.assert not %(py2)s
{%(py2)s = %(py0)s.locked
}r  rX   Fz
foo.lock()zfoo.unlock())r    r   r   r
  r   r+   rx   r   r   r  r   r	   lockr!  lockedr8   r9   r6   r:   r;   r<   r=   unlockr   ro   r  r  )r?   r  r    ry   r&   r!  r@   r   rB   rF   r+   r   r   r   test_lock_unlock_statusb  s4    	
	  S  
	   S  
	z/TestSvnWCAuthFunctional.test_lock_unlock_statusc             C   s  | j  } t j j | j d | j } | j d | | j j f  | j	 d d d | j
 d  | j   t | j   j  } | j d  } | j d  | j   } d } | | k } | sRt j d | f d | | f  d t j |  d d t j   k st j |  r#t j |  n d i }	 d d |	 i }
 t t j |
    d  } } | j
 d  | j   } | } | sd d d t j   k st j |  rt j |  n d i } t t j |    d  } | j d |  } d } | | k } | st j d | f d | | f  d t j |  d d t j   k sXt j |  rgt j |  n d i }	 d d |	 i }
 t t j |
    d  } } t d d d d } | | _ t j j t d  d  S) Nr+   zsvn://localhost:%s/%sr&   r   Tzadded foo filer'   z
+bar
r   %(py1)s in %(py3)sr2   r4   diffr.   assert %(py5)sr,   zadded some contentassert not %(py0)sr*   r   r  rX   Fzfoo.diff(rev=rev))r   )r&  r(  r)  )r   )r&  r(  )r    r   r   r
  r   r+   rx   r   r   r  r   r  r   r!  r   r	   r
   r'  r6   r7   r;   r8   r9   r:   r<   r=   r   ro   r  r  )r?   r  r    ry   r   r&   r'  rz   rE   rF   rC   r@   @py_format2r+   r   r   r   	test_diffv  sH    	
   j   
  @     j   
	z!TestSvnWCAuthFunctional.test_diffN)r_   r`   ra   r  r  r  r   r  r  r%  r+  r   r   r   r   r  %  s   
r  c               @   s4   e  Z d  Z d d   Z d d   Z d d   Z d S)TestSvnURLAuthFunctionalc          
   C   s  | j  } t j j d | | j j f d | j } | j d  | j   } t	 |  } d } | | k } | sEt
 j d | f d | | f  d d t j   k s t
 j |  r t
 j |  n d d	 t
 j |  d
 d t j   k s t
 j t	  rt
 j t	  n d d t
 j |  i } d d | i }	 t t
 j |	    d  } } } | d }
 |
 j } | j } | | k } | s.t
 j d | f d  | | f  d t
 j |  d d t j   k st
 j |  rt
 j |  n d d t
 j |
  d t
 j |  i } d! d | i } t t
 j |    d  }
 } } } t d d d d } t j j d | | j j f d | } t j j t d  d  S)"Nzsvn://localhost:%s/%sr+   r&   r   r(   0%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py6)sr2   r   rv   r*   r   r4   r.   assert %(py8)sr   r   r   F%(py3)s
{%(py3)s = %(py1)s.auth
} is %(py7)s
{%(py7)s = %(py5)s.auth
}r0   r,   r  assert %(py9)srK   r'   rX   Fzu.listdir())r(   )r-  r.  )r   )r/  r0  )r    r   r   r  r   r   r+   r  r   r   r6   r7   r8   r9   r:   r;   r<   r=   r   ro   r  r  )r?   r  r    r   r   rE   rN   rA   r|   r   rz   rM   rD   rO   r+   r   r   r   r     s8    		       
 	 	      		z%TestSvnURLAuthFunctional.test_listdirc          
   C   s	  | j  } t j j d | | j j f d | j } | j d  } | j } |   } | s d d d d t	 j
   k s t j |  r t j |  n d d t j |  d t j |  i } t t j |    d  } } | j d	  } | j |  | j } |   } | sd d d d	 t	 j
   k s;t j |  rJt j |  n d	 d t j |  d t j |  i } t t j |    d  } } | j } | j }	 | |	 k } | st j d | f d | |	 f  d t j |	  d d	 t	 j
   k st j |  rt j |  n d	 d t j |  d d t	 j
   k sKt j |  rZt j |  n d i }
 d d |
 i } t t j |    d  } } }	 t d d	 d d } t j j d | | j j f d | } | j d  } | j d	  } t j j t d  d  S)Nzsvn://localhost:%s/%sr+   r&   r.   z@assert %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.check
}()
}r*   r-   rI   r'   r   F%(py2)s
{%(py2)s = %(py0)s.auth
} is %(py6)s
{%(py6)s = %(py4)s.auth
}rv   r  assert %(py8)sr   rX   Fzfoo.copy(bar))r   )r1  r2  )r    r   r   r  r   r   r+   r   r   r8   r9   r6   r:   r;   r<   r=   r	   r   r7   r   ro   r  r  )r?   r  r    r   r&   r@   rB   r{   r'   rN   r|   r   r+   r   r   r   r     sD    			 	  b  
	 	  b  
	 	      		z"TestSvnURLAuthFunctional.test_copyc             C   s  | j  } t j j d | | j j f d | j } | j d  } | j   } z | j	   } Wd  | j
   Xd } | | k } | st j d | f d | | f  d d t j   k s t j |  r t j |  n d d	 t j |  i }	 d d |	 i }
 t t j |
    d  } } t d d d d } t j j d | | j j f d | } | j d  } t j j t d  d  S)Nzsvn://localhost:%s/%sr+   r&   r.   r(   %(py0)s == %(py3)sr*   datar4   assert %(py5)sr,   r'   rX   Fz
foo.open())r(   )r3  r5  )r    r   r   r  r   r   r+   r  r   r   closer6   r7   r8   r9   r:   r;   r<   r=   r   r	   ro   r  r  )r?   r  r    r   r&   fpr4  rE   r@   rF   rC   r+   r   r   r   test_write_read  s,    		   j   
		z(TestSvnURLAuthFunctional.test_write_readN)r_   r`   ra   r   r   r8  r   r   r   r   r,    s   r,  )builtinsr8   _pytest.assertion.rewrite	assertionrewriter6   r   ZsvntestbaseZpy.pathr   r   r   r   r   sysfindrn   r   r$   objectr%   r
  rb   rl   r  r   r   r   r   r  r,  r   r   r   r   <module>   s$     	uh