ó
šxTc           @   s©  d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l	 Z	 d  d l
 Z
 d  d l Z d  d l Z d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d	 e j f d
 „  ƒ  YZ d e j f d „  ƒ  YZ e j ƒ  j e ƒ Z e j ƒ  j e ƒ Z e j ƒ  j e ƒ Z e j ƒ  j e ƒ Z e j ƒ  j e ƒ Z e j e e e e e g ƒ Z e j d d ƒ j e ƒ d S(   iÿÿÿÿ(   t   servicesNt   TestValidatorc           B   s   e  Z d  „  Z RS(   c         C   ss   t  j d d „  d t  j d d ƒ } |  j | j d ƒ d ƒ |  j t  j | j d ƒ |  j t  j | j d  ƒ d  S(   Nt   checkc         S   s   |  S(   N(    (   t   s(    (    sJ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/pipeline/tst_services.pyt   <lambda>   s    t	   exceptiont   messages	   Not foundt   Foot    (   R    t	   Validatort   NotFoundExceptiont   assertEqualt   processt   assertRaisest   None(   t   selft	   validator(    (    sJ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/pipeline/tst_services.pyt   testNotFoundIsEmpty   s    				(   t   __name__t
   __module__R   (    (    (    sJ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/pipeline/tst_services.pyR      s   t   TestFilterProcessorc           B   s   e  Z d  „  Z RS(   c         C   s–   t  j d d „  ƒ } |  j | j d ƒ d ƒ |  j | j d ƒ d ƒ |  j | j d ƒ d ƒ |  j | j d ƒ d ƒ |  j | j d  ƒ d  ƒ d  S(   Nt
   conversionc         S   s   |  r |  j  ƒ  S|  S(   N(   t   lower(   R   (    (    sJ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/pipeline/tst_services.pyR   .   s    t   3adkt   3ADKt   3ADkR   (   R    t   FilterProcessorR   R   R   (   R   t	   processor(    (    sJ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/pipeline/tst_services.pyt   testProcess+   s    	(   R   R   R   (    (    (    sJ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/pipeline/tst_services.pyR   )   s   t   TestExtractProcessorc           B   s   e  Z d  „  Z RS(   c         C   s‰   t  j d t j d t j ƒ ƒ } |  j | j d ƒ d ƒ |  j | j d ƒ d ƒ |  j | j d ƒ d ƒ |  j t  j | j d ƒ d  S(	   Nt   regexs   <pre>(.*)</pre>s   <pre>Some random data</pre>s   Some random datas*   <title><pre>Some random data</pre></title>s   <pre></pre>R   s   <pre>Some random data</pre(	   R    t   ExtractProcessort   ret   compilet   DOTALLR   R   R   t   UnexpectedResponse(   R   R   (    (    sJ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/pipeline/tst_services.pyR   :   s    	(   R   R   R   (    (    (    sJ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/pipeline/tst_services.pyR   8   s   t   TestGunzipProcessorc           B   s   e  Z d  „  Z RS(   c         C   s�   d } t  j  ƒ  } t j d | d d ƒ } | j | ƒ | j ƒ  | j ƒ  } t j ƒ  } |  j | j	 | ƒ | ƒ |  j
 t j | j	 | ƒ d  S(   Ns   Some random datat   fileobjt   modet   wb(   t   StringIOt   gzipt   GzipFilet   writet   closet   getvalueR    t   GunzipProcessorR   R   R   R#   (   R   t   datat   compressed_data_filet   compressor_streamt   compressed_dataR   (    (    sJ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/pipeline/tst_services.pyR   U   s    
(   R   R   R   (    (    (    sJ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/pipeline/tst_services.pyR$   S   s   t   TestMemoryMemoizerc           B   s;   e  Z d  Z d Z d Z d Z d „  Z d „  Z d „  Z RS(   s	   Some datas   Some other datas   Some distinct datas   Some default datac         C   sQ   t  j d ƒ | d k r  |  j S| d k r3 |  j S| d k rF |  j S|  j Sd  S(   Ng      ð?i   i   i   (   t   timet   sleept   DATA1t   DATA2t   DATA3t   DATA4(   R   t
   identifier(    (    sJ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/pipeline/tst_services.pyt   slow_methodo   s    c         C   s9  t  j ƒ  } |  j | j i  ƒ | j d d d |  j ƒ | j d d d |  j ƒ |  j | j d d ƒ ƒ |  j | j d d ƒ ƒ |  j | j d d ƒ ƒ |  j | j i |  j d 6|  j d 6ƒ |  j | j	 d d ƒ |  j ƒ |  j | j	 d d ƒ |  j ƒ |  j
 t | j	 d ƒ | j ƒ  |  j | j i  ƒ d  S(   Nt   keyi   R/   i   i   (   R    t   MemoryMemoizerR   t   cachet   insertR6   R7   t   assert_t   containst   retrieveR   t   KeyErrort   purge(   R   t   memoizer(    (    sJ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/pipeline/tst_services.pyt   testCaching€   s"    

c         C   s¬  t  j  ƒ  } |  j |  j d ƒ |  j ƒ t  j  ƒ  } |  j | | d d ƒ t j ƒ  } |  j } | j |  j d t j j	 ƒ|  j
 | |  j k ƒ |  j
 t |  j d ƒ ƒ |  j
 t |  j t j ƒ ƒ t  j  ƒ  } |  j |  j d ƒ |  j ƒ t  j  ƒ  } |  j | | d d ƒ t  j  ƒ  } |  j |  j d ƒ |  j ƒ |  j |  j d ƒ |  j ƒ |  j |  j d ƒ |  j ƒ |  j |  j d ƒ |  j ƒ t  j  ƒ  } |  j | | d d ƒ t  j  ƒ  } |  j |  j d ƒ |  j ƒ t  j  ƒ  } |  j | | d d ƒ t  j  ƒ  } |  j |  j d ƒ |  j ƒ |  j |  j d ƒ |  j ƒ |  j |  j d ƒ |  j ƒ |  j |  j d ƒ |  j ƒ t  j  ƒ  } |  j | | d d ƒ |  j | j i |  j d 6|  j d 6ƒ | j ƒ  t  j  ƒ  } |  j |  j d ƒ |  j ƒ t  j  ƒ  } |  j | j i |  j d 6ƒ | j |  j ƒ |  j
 | |  j k ƒ |  j
 t |  j d ƒ ƒ t  j  ƒ  } |  j |  j d ƒ |  j ƒ t  j  ƒ  } |  j | | d d ƒ d  S(   Ni   g      ð?t   key_generatort   functiong        i   i   (   R4   R   R;   R6   t   assertAlmostEqualR    R=   t   attach_methodt   MemoizedFunctiont
   simple_keyR@   t   hasattrt
   isinstanceR9   R>   RD   R8   t   detach_method(   R   t   startt   endRE   t   original_method(    (    sJ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/pipeline/tst_services.pyt   testMemoizeœ   sl    		

(	   R   R   R6   R7   R8   R9   R;   RF   RS   (    (    (    sJ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/pipeline/tst_services.pyR3   h   s   		t	   verbosityi   (   t   phaser.pipelineR    t	   iotbx.pdbt   iotbxt   unittestt   urllib2t   urllibR(   R)   R    R4   t   ost   tempfilet   TestCaseR   R   R   R$   R3   t
   TestLoadert   loadTestsFromTestCaset   suite_validatort   suite_filter_processort   suite_extract_processort   suite_gunzip_processort   suite_memory_memoizert	   TestSuitet   alltestst   TextTestRunnert   run(    (    (    sJ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/pipeline/tst_services.pyt   <module>   sD   ÿ ÿ Õ					