ó
q®¸Qc           @   sÕ   d  Z  d d l Z d d l Z d d l m Z d d l m Z d d l m Z d d l	 m
 Z
 d d l m Z m Z d Z d Z d	 e f d
 „  ƒ  YZ d e f d „  ƒ  YZ d „  Z e d k rÑ e e ƒ  ƒ n  d S(   s#   Tests for distutils.command.upload.iÿÿÿÿN(   t   run_unittest(   t   upload(   t   Distribution(   t   PYPIRCt   PyPIRCCommandTestCasesñ   [distutils]

index-servers =
    server1
    server2

[server1]
username:me
password:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

[server2]
username:meagain
password: secret
realm:acme
repository:http://another.pypi/
s@   [distutils]

index-servers =
    server1

[server1]
username:me
t   FakeOpenc           B   s   e  Z d  „  Z d „  Z RS(   c         C   s:   | |  _  t | t ƒ s$ | |  _ n	 d  |  _ d |  _ d  S(   Nt   OK(   t   urlt
   isinstancet   strt   reqt   Nonet   msg(   t   selfR   (    (    s1   /sys/lib/python2.7/distutils/tests/test_upload.pyt   __init__,   s
    		c         C   s   d S(   NiÈ   (    (   R   (    (    s1   /sys/lib/python2.7/distutils/tests/test_upload.pyt   getcode4   s    (   t   __name__t
   __module__R   R   (    (    (    s1   /sys/lib/python2.7/distutils/tests/test_upload.pyR   *   s   	t   uploadTestCasec           B   s>   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s8   t  t |  ƒ j ƒ  t j |  _ |  j t _ d  |  _ d  S(   N(	   t   superR   t   setUpt
   upload_modt   urlopent   old_opent   _urlopenR   t	   last_open(   R   (    (    s1   /sys/lib/python2.7/distutils/tests/test_upload.pyR   :   s    c         C   s#   |  j  t _ t t |  ƒ j ƒ  d  S(   N(   R   R   R   R   R   t   tearDown(   R   (    (    s1   /sys/lib/python2.7/distutils/tests/test_upload.pyR   @   s    c         C   s   t  | ƒ |  _ |  j S(   N(   R   R   (   R   R   (    (    s1   /sys/lib/python2.7/distutils/tests/test_upload.pyR   D   s    c         C   sr   |  j  |  j t ƒ t ƒ  } t | ƒ } | j ƒ  x9 d	 d
 d d f D]% \ } } |  j t | | ƒ | ƒ qE Wd  S(   Nt   usernamet   met   passwordt   secrett   realmt   pypit
   repositorys   http://pypi.python.org/pypi(   R   R   (   s   passwordR   (   R   R    (   R!   s   http://pypi.python.org/pypi(   t
   write_filet   rcR   R   R   t   finalize_optionst   assertEqualt   getattr(   R   t   distt   cmdt   attrt   waited(    (    s1   /sys/lib/python2.7/distutils/tests/test_upload.pyt   test_finalize_optionsH   s    	
	c         C   s{   |  j  |  j t ƒ t ƒ  } t | ƒ } | j ƒ  |  j | j d  ƒ d | _ t | ƒ } | j ƒ  |  j | j d ƒ d  S(   Nt   xxx(	   R"   R#   t   PYPIRC_NOPASSWORDR   R   R$   R%   R   R   (   R   R'   R(   (    (    s1   /sys/lib/python2.7/distutils/tests/test_upload.pyt   test_saved_passwordT   s    	
	
c         C   s  |  j  ƒ  } t j j | d ƒ } |  j | ƒ d d | } } } | | | f g } |  j |  j t ƒ |  j d | d d ƒ \ } } t | ƒ }	 |	 j	 ƒ  |	 j
 ƒ  |  j d |  j j j ƒ t |  j j j ƒ }
 |  j |
 d d ƒ |  j |
 d	 j d
 ƒ ƒ |  j |  j j j ƒ  d ƒ |  j |  j j j ƒ  d ƒ |  j d |  j j j k ƒ |  j j j d } |  j d | k ƒ d  S(   NR,   s   2.6t
   dist_filest   authoru   dÃ©dÃ©s   dÃ©dÃ©s   Content-lengtht   2085s   Content-types   multipart/form-datat   POSTs   http://pypi.python.org/pypit   Authorizations   
(   t   mkdtempt   ost   patht   joinR"   R#   t   PYPIRC_LONG_PASSWORDt   create_distR   t   ensure_finalizedt   runt   assertInR   R
   t   datat   dictt   headersR%   t
   assertTruet
   startswitht
   get_methodt   get_full_urlt   assertFalse(   R   t   tmpR6   t   commandt	   pyversiont   filenameR/   t   pkg_dirR'   R(   R?   t   auth(    (    s1   /sys/lib/python2.7/distutils/tests/test_upload.pyt   test_uploade   s(    

(   R   R   R   R   R   R+   R.   RK   (    (    (    s1   /sys/lib/python2.7/distutils/tests/test_upload.pyR   8   s   					c           C   s   t  j t ƒ S(   N(   t   unittestt	   makeSuiteR   (    (    (    s1   /sys/lib/python2.7/distutils/tests/test_upload.pyt
   test_suite   s    t   __main__(   t   __doc__R5   RL   t   test.test_supportR    t   distutils.commandR   R   t   distutils.command.uploadt   distutils.coreR   t   distutils.tests.test_configR   R   R8   R-   t   objectR   R   RN   R   (    (    (    s1   /sys/lib/python2.7/distutils/tests/test_upload.pyt   <module>   s   G	