ó
šßÈ[c           @   så   d  Z  d d l Z d d l Z d d l Z d d l m Z d d l m Z m Z d d l	 m
 Z
 d d l m Z m Z d	 d
 l m Z m Z d d l m Z m Z d d l m Z d	 d l m Z d „  Z d e f d „  ƒ  YZ d S(   sï   
Test the web profile using Python classes that have been adapted to act like a
web client. We can only put a single test here because only one hub can run
with the web profile active, and the user might want to run the tests in
parallel.
iÿÿÿÿNi   (   t   six(   t   Requestt   urlopen(   t   get_readable_fileobji   (   t   SAMPIntegratedClientt   SAMPHubServeri   (   t   AlwaysApproveWebProfileDialogt   SAMPIntegratedWebClient(   t   CROSS_DOMAINt   CLIENT_ACCESS_POLICY(   t   conf(   t   TestStandardProfilec         C   s   t  t _ d  S(   N(   t   FalseR
   t   use_internet(   t   module(    (    sB   lib/python2.7/site-packages/astropy/samp/tests/test_web_profile.pyt   setup_module   s    t   TestWebProfilec           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c      	   C   s(  t  ƒ  |  _ t j d |  j j ƒ } | j ƒ  t j ƒ  |  _ t	 j
 j |  j d ƒ } t d |  j d | d d d d ƒ |  _ |  j j ƒ  t ƒ  |  _ |  j j d	 |  j d d ƒ |  j j ƒ  |  _ |  j j ƒ  |  _ t ƒ  |  _ |  j j d |  j j d d
 ƒ |  j j ƒ  |  _ |  j j ƒ  |  _ d  S(   Nt   targets   .sampt   web_profile_dialogt   lockfilet   web_porti    t	   pool_sizei   t   hubi   (   R   t   dialogt	   threadingt   Threadt   pollt   startt   tempfilet   mkdtempt   tmpdirt   ost   patht   joinR   R   R   t   client1t   connectt   get_public_idt
   client1_idt   get_private_keyt   client1_keyR   t   client2t	   _web_portt
   client2_idt   client2_key(   t   selft   methodt   tR   (    (    sB   lib/python2.7/site-packages/astropy/samp/tests/test_web_profile.pyt   setup_method!   s"    
c         C   sV   |  j  j r |  j  j ƒ  n  |  j j r8 |  j j ƒ  n  |  j j ƒ  |  j j ƒ  d  S(   N(   R"   t   is_connectedt
   disconnectR(   R   t   stopR   (   R,   R-   (    (    sB   lib/python2.7/site-packages/astropy/samp/tests/test_web_profile.pyt   teardown_method9   s    c         C   ss  t  d j |  j j ƒ ƒ  } | j ƒ  t k s6 t ‚ Wd  QXt  d j |  j j ƒ ƒ  } | j ƒ  t k sr t ‚ Wd  QXt d j |  j j ƒ ƒ } | j	 d d ƒ t
 | ƒ } t j r| j ƒ  j d ƒ d k sÙ t ‚ | j ƒ  j d ƒ d k sú t ‚ | j ƒ  j d ƒ d	 k sot ‚ nQ | j d ƒ d k s9t ‚ | j d ƒ d k sTt ‚ | j d ƒ d	 k sot ‚ d  S(
   Ns$   http://localhost:{0}/crossdomain.xmls+   http://localhost:{0}/clientaccesspolicy.xmlt   Origint   test_web_profiles   Access-Control-Allow-Origins   Access-Control-Allow-Headerss   Content-Types    Access-Control-Allow-Credentialst   true(   R   t   formatR   R)   t   readR   t   AssertionErrorR	   R   t
   add_headerR   R    t   PY2t   infot	   getheader(   R,   t   ft   reqt   resp(    (    sB   lib/python2.7/site-packages/astropy/samp/tests/test_web_profile.pyR5   F   s    	!!$(   t   __name__t
   __module__R/   R3   R5   (    (    (    sB   lib/python2.7/site-packages/astropy/samp/tests/test_web_profile.pyR      s   		(   t   __doc__R   R   R   t   externR    t   extern.six.moves.urllib.requestR   R   t
   utils.dataR   t    R   R   t   web_profile_test_helpersR   R   t   web_profileR   R	   R
   t   test_standard_profileR   t   BaseTestStandardProfileR   R   (    (    (    sB   lib/python2.7/site-packages/astropy/samp/tests/test_web_profile.pyt   <module>   s   	