ó
Y[c           @   sl   d  Z  d d l Z d d l Z d d l Z d d l Z d e j f d „  ƒ  YZ e d k rh e j ƒ  n  d S(   s   Tests for certbot.reporter.iÿÿÿÿNt   ReporterTestc           B   sz   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z RS(   s$   Tests for certbot.reporter.Reporter.c         C   sM   d d l  m } | j t j d t ƒ ƒ |  _ t j |  _ t	 j
 ƒ  t _ d  S(   Niÿÿÿÿ(   t   reportert   quiet(   t   certbotR   t   Reportert   mockt	   MagicMockt   Falset   syst   stdoutt
   old_stdoutt   sixt   StringIO(   t   selfR   (    (    s?   /usr/lib/python2.7/dist-packages/certbot/tests/reporter_test.pyt   setUp   s    c         C   s   |  j  t _ d  S(   N(   R
   R   R	   (   R   (    (    s?   /usr/lib/python2.7/dist-packages/certbot/tests/reporter_test.pyt   tearDown   s    c         C   s_   |  j  j d |  j  j ƒ |  j  j ƒ  t j j ƒ  } |  j d | k ƒ |  j d | k ƒ d  S(   Ns   Line 1
Line 2s   Line 1
s   Line 2(   R   t   add_messaget   LOW_PRIORITYt   print_messagesR   R	   t   getvaluet
   assertTrue(   R   t   output(    (    s?   /usr/lib/python2.7/dist-packages/certbot/tests/reporter_test.pyt   test_multiline_message   s
    c         C   s   d „  t  j _ |  j ƒ  d  S(   Nc           S   s   t  S(   N(   t   True(    (    (    s?   /usr/lib/python2.7/dist-packages/certbot/tests/reporter_test.pyt   <lambda>   s    (   R   R	   t   isattyt   test_no_tty_print_empty(   R   (    (    s?   /usr/lib/python2.7/dist-packages/certbot/tests/reporter_test.pyt   test_tty_print_empty   s    c         C   sn   |  j  j ƒ  |  j t j j ƒ  d ƒ y
 t ‚ Wn t k
 rP |  j  j ƒ  n X|  j t j j ƒ  d ƒ d  S(   Nt    (   R   R   t   assertEqualR   R	   R   t
   ValueError(   R   (    (    s?   /usr/lib/python2.7/dist-packages/certbot/tests/reporter_test.pyR       s    
c         C   s   d „  t  j _ |  j ƒ  d  S(   Nc           S   s   t  S(   N(   R   (    (    (    s?   /usr/lib/python2.7/dist-packages/certbot/tests/reporter_test.pyR   *   s    (   R   R	   R   t   _successful_exit_common(   R   (    (    s?   /usr/lib/python2.7/dist-packages/certbot/tests/reporter_test.pyt   test_tty_successful_exit)   s    c         C   s   |  j  ƒ  d  S(   N(   R   (   R   (    (    s?   /usr/lib/python2.7/dist-packages/certbot/tests/reporter_test.pyt   test_no_tty_successful_exit-   s    c         C   s   d „  t  j _ |  j ƒ  d  S(   Nc           S   s   t  S(   N(   R   (    (    (    s?   /usr/lib/python2.7/dist-packages/certbot/tests/reporter_test.pyR   1   s    (   R   R	   R   t   _unsuccessful_exit_common(   R   (    (    s?   /usr/lib/python2.7/dist-packages/certbot/tests/reporter_test.pyt   test_tty_unsuccessful_exit0   s    c         C   s   |  j  ƒ  d  S(   N(   R"   (   R   (    (    s?   /usr/lib/python2.7/dist-packages/certbot/tests/reporter_test.pyt   test_no_tty_unsuccessful_exit4   s    c         C   sv   |  j  ƒ  |  j j ƒ  t j j ƒ  } |  j d | k ƒ |  j d | k ƒ |  j d | k ƒ |  j d | k ƒ d  S(   Ns   IMPORTANT NOTES:t   Hight   Medt   Low(   t   _add_messagesR   R   R   R	   R   R   (   R   R   (    (    s?   /usr/lib/python2.7/dist-packages/certbot/tests/reporter_test.pyR   7   s    
c         C   s”   |  j  ƒ  y
 t ‚ Wn t k
 r4 |  j j ƒ  n Xt j j ƒ  } |  j d | k ƒ |  j d | k ƒ |  j d | k ƒ |  j d | k ƒ d  S(   Ns   IMPORTANT NOTES:R%   R&   R'   (   R(   R   R   R   R   R	   R   R   (   R   R   (    (    s?   /usr/lib/python2.7/dist-packages/certbot/tests/reporter_test.pyR"   @   s    

c         C   s[   |  j  j d |  j  j ƒ |  j  j d |  j  j d t ƒ|  j  j d |  j  j d t ƒd  S(   NR%   R&   t   on_crashR'   (   R   R   t   HIGH_PRIORITYt   MEDIUM_PRIORITYR   R   (   R   (    (    s?   /usr/lib/python2.7/dist-packages/certbot/tests/reporter_test.pyR(   L   s
    		(   t   __name__t
   __module__t   __doc__R   R   R   R   R   R    R!   R#   R$   R   R"   R(   (    (    (    s?   /usr/lib/python2.7/dist-packages/certbot/tests/reporter_test.pyR    	   s   													t   __main__(	   R.   R   R   t   unittestR   t   TestCaseR    R,   t   main(    (    (    s?   /usr/lib/python2.7/dist-packages/certbot/tests/reporter_test.pyt   <module>   s   K