ó
E®Uc           @   sž   d  Z  d d l m Z d d l m Z d d l m Z d d l m Z d d l	 Z
 d e
 j j f d „  ƒ  YZ d	 e f d
 „  ƒ  YZ d e f d „  ƒ  YZ d S(   s   Tests for samba.netcmd.iÿÿÿÿ(   t   StringIO(   t   Command(   t   cmd_testparm(   t   cmd_sambatoolNt   NetCmdTestCasec           B   s   e  Z d  d „ Z d „  Z RS(   i    c         C   s‰   | d t  ƒ  d t  ƒ  ƒ } y | j | j | Œ } Wn& t k
 r\ } | j | ƒ d } n X|  j | | ƒ | j j ƒ  | j j ƒ  f S(   Nt   outft   errfi   (	   R    t   _runt   __name__t	   Exceptiont   show_command_errort   assertEqualsR   t   getvalueR   (   t   selft	   cmd_klasst   argst   retcodet   cmdt   retvalt   e(    (    s6   /usr/lib/python2.7/dist-packages/samba/tests/netcmd.pyt
   run_netcmd   s    
c         c   s–   g  } | j  t j j ƒ  ƒ xs | r‘ | j ƒ  \ } } | | f Vt | d i  ƒ } | j  g  | j ƒ  D]  \ } } | d | | f ^ qg ƒ q Wd  S(   Nt   subcommandst    (   t   extendR   R   t   itemst   popt   getattrt	   iteritems(   R   t   todot   pathR   t   subcmdst   kt   v(    (    s6   /usr/lib/python2.7/dist-packages/samba/tests/netcmd.pyt   iter_all_subcommands&   s    		(   R   t
   __module__R   R!   (    (    (    s6   /usr/lib/python2.7/dist-packages/samba/tests/netcmd.pyR      s   
t   TestParmTestsc           B   s   e  Z d  „  Z RS(   c         C   sE   |  j  t d g d d ƒ\ } } |  j d | ƒ |  j d | ƒ d  S(   Ns   --client-name=fooR   iÿÿÿÿt    sP   ERROR: Both a DNS name and an IP address are required for the host access check
(   R   R   R   (   R   t   outt   err(    (    s6   /usr/lib/python2.7/dist-packages/samba/tests/netcmd.pyt   test_no_client_ip3   s    (   R   R"   R'   (    (    (    s6   /usr/lib/python2.7/dist-packages/samba/tests/netcmd.pyR#   1   s   t   CommandTestsc           B   s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         C   s0   d t  f d „  ƒ  Y} |  j d | ƒ  j ƒ d  S(   Nt   cmd_fooc           B   s   e  Z d  Z RS(   t   Mydescription(   R   R"   t   __doc__(    (    (    s6   /usr/lib/python2.7/dist-packages/samba/tests/netcmd.pyR)   ?   s   R*   (   R   R   t   short_description(   R   R)   (    (    s6   /usr/lib/python2.7/dist-packages/samba/tests/netcmd.pyt   test_description>   s    c         C   s0   d t  f d „  ƒ  Y} |  j d | ƒ  j ƒ d  S(   NR)   c           B   s   e  Z RS(    (   R   R"   (    (    (    s6   /usr/lib/python2.7/dist-packages/samba/tests/netcmd.pyR)   D   s   t   foo(   R   R   t   name(   R   R)   (    (    s6   /usr/lib/python2.7/dist-packages/samba/tests/netcmd.pyt	   test_nameC   s    c         C   s`   g  } x9 |  j  ƒ  D]+ \ } } | j d  k r | j | ƒ q q W| r\ |  j d | ƒ n  d  S(   Ns5   The following commands do not have a synopsis set: %r(   R!   t   synopsist   Nonet   appendt   fail(   R   t   missingR   R   (    (    s6   /usr/lib/python2.7/dist-packages/samba/tests/netcmd.pyt   test_synopsis_everywhereH   s    	c         C   sa   g  } x9 |  j  ƒ  D]+ \ } } | j d  k r | j | ƒ q q W| sL d  S|  j d | ƒ d  S(   Ns>   The following commands do not have a short description set: %r(   R!   R,   R2   R3   R4   (   R   R5   R   R   (    (    s6   /usr/lib/python2.7/dist-packages/samba/tests/netcmd.pyt!   test_short_description_everywhereQ   s    (   R   R"   R-   R0   R6   R7   (    (    (    s6   /usr/lib/python2.7/dist-packages/samba/tests/netcmd.pyR(   <   s   				(   R+   t	   cStringIOR    t   samba.netcmdR   t   samba.netcmd.testparmR   t   samba.netcmd.mainR   t   samba.testst   sambat   testst   TestCaseR   R#   R(   (    (    (    s6   /usr/lib/python2.7/dist-packages/samba/tests/netcmd.pyt   <module>   s   