ó
Ò:\c           @   sÓ   d  Z  d d l 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 e j d d ƒ d „  ƒ Z e j d	 „  ƒ Z e j d
 „  ƒ Z e j d d d d g ƒ d „  ƒ Z d S(   s   Pytest testing utilities.iÿÿÿÿN(   t   AnacondaAPI(   t   CONF_VERSIONt   DEFAULTS(   t
   UserConfigt   scopet   functionc      
      sj   t  j ƒ  ‰  t d d t d t d ˆ  d t ƒ} | j ƒ  t ƒ  j d ƒ ‡  f d †  } |  j	 | ƒ | S(   s=   Return a temporal configuration object and delete after used.s   anaconda-navigator-testt   defaultst   versiont	   subfoldert   raw_modes   https://api.anaconda.orgc              s   t  j ˆ  ƒ d  S(   N(   t   shutilt   rmtree(    (   t	   SUBFOLDER(    s@   lib/python2.7/site-packages/anaconda_navigator/utils/fixtures.pyt   fin&   s    (
   t   tempfilet   mkdtempR   R   R   t   Truet   reset_to_defaultsR    t   client_set_api_urlt   addfinalizer(   t   requestt   CONFR   (    (   R   s@   lib/python2.7/site-packages/anaconda_navigator/utils/fixtures.pyt	   tmpconfig   s    	
c            s,   t  j ƒ  ‰  ‡  f d †  } |  j | ƒ ˆ  S(   s4   Return a temporal folder path and delete after used.c              s   t  j ˆ  ƒ d  S(   N(   R
   R   (    (   t   folder(    s@   lib/python2.7/site-packages/anaconda_navigator/utils/fixtures.pyR   2   s    (   R   R   R   (   R   R   (    (   R   s@   lib/python2.7/site-packages/anaconda_navigator/utils/fixtures.pyt	   tmpfolder-   s    c         C   s,   t  j ƒ  \ } } d „  } |  j | ƒ | S(   s2   Return a temporal file path and delete after used.c           S   s	   d GHd  S(   Ns   tmpfile finalizer(    (    (    (    s@   lib/python2.7/site-packages/anaconda_navigator/utils/fixtures.pyR   >   s    (   R   t   mkstempR   (   R   t   _t   pathR   (    (    s@   lib/python2.7/site-packages/anaconda_navigator/utils/fixtures.pyt   tmpfile9   s    	t   paramst   eventst   videost   webinarsc   	         s¢   d } | j  ˆ  j ƒ } t j d d d t ƒ \ } } t ƒ  } t j | d | j ƒ  ƒ} t	 | d ƒ  } | j
 | j ƒ Wd QX‡  f d †  } ˆ  j | ƒ | S(	   s4   Return a temporal file path with downloaded content.s.   http://anaconda.com/api/{0}?items_per_page=allt   suffixt   jsont   textt   proxiest   wNc              s   d j  ˆ  j ƒ GHd  S(   Ns   Finalizing production {0} check(   t   formatt   param(    (   R   (    s@   lib/python2.7/site-packages/anaconda_navigator/utils/fixtures.pyR   P   s    (   R&   R'   R   R   R   R    t   requestst   gett   conda_load_proxy_configt   opent   writeR#   R   (	   R   t   content_base_urit   urlR   R   t   apit   rt   fR   (    (   R   s@   lib/python2.7/site-packages/anaconda_navigator/utils/fixtures.pyt   tmpjsonfile_productionE   s    	(   t   __doc__R
   R   t   pytestR(   t#   anaconda_navigator.api.anaconda_apiR    t   anaconda_navigator.config.mainR   R   t   anaconda_navigator.config.userR   t   fixtureR   R   R   R2   (    (    (    s@   lib/python2.7/site-packages/anaconda_navigator/utils/fixtures.pyt   <module>   s   