ó
Y[c           @   s¦   d  Z  d d l Z d d l Z d d l m Z d d l m Z d d l m Z d d l m Z d d l	 j
 j Z d e j f d „  ƒ  YZ e d	 k r¢ e j ƒ  n  d S(
   s$   Tests for renewal updater interfacesiÿÿÿÿN(   t
   interfaces(   t   main(   t   updater(   t   enhancementst   RenewUpdaterTestc           B   sõ   e  Z d  Z d „  Z e j d ƒ e j d ƒ e j d ƒ e j ƒ  d „  ƒ ƒ ƒ ƒ Z d „  Z	 e j d ƒ d „  ƒ Z
 e j d ƒ d	 „  ƒ Z e j d ƒ d
 „  ƒ Z d „  Z e j d ƒ d „  ƒ Z d „  Z e j d ƒ d „  ƒ Z d „  Z RS(   s@   Tests for interfaces.RenewDeployer and interfaces.GenericUpdaterc         C   sq   t  t |  ƒ j ƒ  t j d t j ƒ |  _ t j ƒ  |  j _ t j d t j	 ƒ |  _
 t j d t j ƒ |  _ d  S(   Nt   spec(   t   superR   t   setUpt   mockt	   MagicMockR    t   GenericUpdatert   generic_updatert   restartt   RenewDeployert   renew_deployerR   t   AutoHSTSEnhancementt   mockinstaller(   t   self(    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/renewupdater_test.pyR      s
    s   certbot.main._get_and_save_certs5   certbot.plugins.selection.choose_configurator_pluginss2   certbot.plugins.selection.get_unprepared_installerc         C   sØ   t  j ƒ  | _ |  j } | d  f | _ | | _ t  j d ƒ ! t j |  j d  t  j ƒ  ƒ Wd  QX|  j	 | j
 j ƒ | j
 j ƒ  | j j ƒ  t j |  j t  j ƒ  d  ƒ |  j | j j d ƒ |  j | j
 j ƒ d  S(   Ns   certbot.main._init_le_clienti   (   R   R	   t   return_valueR   t   Nonet   patchR   t
   renew_certt   configt
   assertTrueR   t   calledt
   reset_mockt   generic_updatesR   t   run_generic_updaterst   assertEqualt
   call_countt   assertFalse(   R   t   _t	   mock_getit   mock_selectt   mock_getsavet   mock_generic_updater(    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/renewupdater_test.pyt   test_server_updates   s    		"c         C   sH   t  j ƒ  } |  j } t j |  j | | ƒ |  j | j j | ƒ ƒ d  S(   N(	   R   R	   R   R   t   run_renewal_deployerR   R   t   renew_deployt   called_with(   R   t   lineaget   mock_deployer(    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/renewupdater_test.pyt   test_renew_deployer-   s    	s   certbot.updater.logger.debugc         C   sQ   t  |  j _ t j |  j d  d  ƒ |  j | j ƒ |  j | j	 d d d ƒ d  S(   Ni    s"   Skipping updaters in dry-run mode.(
   t   TrueR   t   dry_runR   R   R   R   R   t   assertEqualst	   call_args(   R   t   mock_log(    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/renewupdater_test.pyt   test_updater_skip_dry_run3   s
    c         C   sQ   t  |  j _ t j |  j d  d  ƒ |  j | j ƒ |  j | j	 d d d ƒ d  S(   Ni    s*   Skipping renewal deployer in dry-run mode.(
   R+   R   R,   R   R%   R   R   R   R-   R.   (   R   R/   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/renewupdater_test.pyt   test_deployer_skip_dry_run;   s
    c         C   s[   |  j  | _ t j |  j t j ƒ  d  ƒ |  j |  j  j	 j
 ƒ |  j |  j  j	 j d ƒ d  S(   Ni   (   R   R   R   R   R   R   R	   R   R   t   update_autohstsR   R   R   (   R   R    (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/renewupdater_test.pyt   test_enhancement_updatesC   s    c         C   s9   t  j |  j t j ƒ  |  j ƒ |  j |  j j j ƒ d  S(   N(	   R   R%   R   R   R	   R   R   t   deploy_autohstsR   (   R   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/renewupdater_test.pyt   test_enhancement_deployerJ   s    
c         C   sN   t  |  j _ |  j | _ t j |  j t j ƒ  d  ƒ |  j
 |  j j j ƒ d  S(   N(   R+   R   t   disable_renew_updatesR   R   R   R   R   R	   R   R   R2   R   (   R   R    (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/renewupdater_test.pyt#   test_enhancement_updates_not_calledO   s    c         C   sE   t  |  j _ t j |  j t j ƒ  |  j ƒ |  j |  j j	 j
 ƒ d  S(   N(   R+   R   R6   R   R%   R   R	   R   R   R4   R   (   R   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/renewupdater_test.pyt$   test_enhancement_deployer_not_calledV   s    
c         C   sŠ   i d d 6t  j d 6d  d 6d d 6d d 6g } |  j | _ t j d	 | ƒ ! t j |  j	 t j
 ƒ  d  ƒ Wd  QX|  j |  j j j ƒ d  S(
   Nt   Testt   namet   classt   updater_functionR4   t   deployer_functiont   enable_autohstst   enable_functions#   certbot.plugins.enhancements._INDEX(   R   R   R   R   R   R   R   R   R   R   R	   R   R2   R   (   R   R    t	   FAKEINDEX(    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/renewupdater_test.pyt   test_enhancement_no_updater\   s    
"c         C   s   i d d 6t  j d 6d d 6d  d 6d d 6g } t j d	 | ƒ $ t j |  j t j ƒ  |  j	 ƒ Wd  QX|  j
 |  j	 j j ƒ d  S(
   NR9   R:   R;   R4   R<   R=   R>   R?   s#   certbot.plugins.enhancements._INDEX(   R   R   R   R   R   R   R%   R   R	   R   R   R4   R   (   R   R@   (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/renewupdater_test.pyt   test_enhancement_no_deployerl   s    
(   t   __name__t
   __module__t   __doc__R   R   R   t	   test_utilt   patch_get_utilityR$   R*   R0   R1   R3   R5   R7   R8   RA   RB   (    (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/renewupdater_test.pyR      s   				t   __main__(   RE   t   unittestR   t   certbotR    R   R   t   certbot.pluginsR   t   certbot.tests.utilt   testst   utilRF   t   ConfigTestCaseR   RC   (    (    (    sC   /usr/lib/python2.7/dist-packages/certbot/tests/renewupdater_test.pyt   <module>   s   n