ó
Y[c           @   s`   d  Z  d d l Z d d l Z d d l Z d e j f d „  ƒ  YZ e d k r\ e j ƒ  n  d S(   s   Tests for certbot.notify.iÿÿÿÿNt   NotifyTestsc           B   st   e  Z d  Z e j d ƒ d „  ƒ Z e j d ƒ e j d ƒ d „  ƒ ƒ Z e j d ƒ e j d ƒ d „  ƒ ƒ Z RS(   s   Tests for the notifier.s   certbot.notify.smtplib.LMTPc         C   sn   d d l  m } t j ƒ  } | | _ |  j | d d d ƒ ƒ |  j | j j d ƒ |  j | j	 j d ƒ d  S(   Niÿÿÿÿ(   t   notifyt   Gooses   auntrhody@example.coms   The old grey goose is dead.i   (
   t   certbot.notifyR   t   mockt	   MagicMockt   return_valuet
   assertTruet   assertEqualt   connectt
   call_countt   sendmail(   t   selft	   mock_lmtpR   t   lmtp_obj(    (    s=   /usr/lib/python2.7/dist-packages/certbot/tests/notify_test.pyt   test_smtp_success   s    	
s   certbot.notify.subprocess.Popenc         C   s˜   d d l  m } t j ƒ  } | | _ t j d ƒ | j _ t j ƒ  } | | _ |  j	 | d d d ƒ ƒ |  j
 | j j d ƒ |  j
 | j j d ƒ d  S(   Niÿÿÿÿ(   R   i   R   s   auntrhody@example.coms   The old grey goose is dead.i   (   R   R   R   R   R   t   sockett   errorR   t   side_effectR   R   R
   t   communicate(   R   t
   mock_popenR   R   R   t   proc(    (    s=   /usr/lib/python2.7/dist-packages/certbot/tests/notify_test.pyt   test_smtp_failure   s    		
c         C   sª   d d l  m } t j ƒ  } | | _ t j d ƒ | j _ t j ƒ  } | | _ t	 d ƒ | j
 _ |  j | d d d ƒ ƒ |  j | j j d ƒ |  j | j
 j d ƒ d  S(	   Niÿÿÿÿ(   R   i   s.   What we have here is a failure to communicate.R   s   auntrhody@example.coms   The old grey goose is dead.i   (   R   R   R   R   R   R   R   R   R   t   OSErrorR   t   assertFalseR   R
   (   R   R   R   R   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/certbot/tests/notify_test.pyt   test_everything_fails#   s    		
(   t   __name__t
   __module__t   __doc__R   t   patchR   R   R   (    (    (    s=   /usr/lib/python2.7/dist-packages/certbot/tests/notify_test.pyR       s   
t   __main__(   R   R   t   unittestR   t   TestCaseR    R   t   main(    (    (    s=   /usr/lib/python2.7/dist-packages/certbot/tests/notify_test.pyt   <module>   s   +