a
    Wa	                     @   st   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
G dd de
jjZG d	d
 d
eZG dd deZdS )zTests for samba.netcmd.    )StringIO)Command)cmd_testparm)cmd_sambatoolNc                   @   s   e Zd ZdddZdd ZdS )NetCmdTestCaser   c              
   C   s|   |t  t  d}z|j|jg|R  }W n2 tyZ } z|| d}W Y d }~n
d }~0 0 | || |j |j fS )N)outferrf   )	r   Z_run__name__	ExceptionZshow_command_errorassertEqualr   getvaluer   )selfZ	cmd_klassargsretcodecmdZretvale r   4/usr/lib/python3/dist-packages/samba/tests/netcmd.py
run_netcmd   s    
zNetCmdTestCase.run_netcmdc                 #   sV   t tj }|rR| \ } |fV  t|di }| fdd| D  qd S )Nsubcommandsc                    s    g | ]\}} d  | |fqS ) r   ).0kvpathr   r   
<listcomp>-       z7NetCmdTestCase.iter_all_subcommands.<locals>.<listcomp>)listr   r   itemspopgetattrextend)r   Ztodor   Zsubcmdsr   r   r   iter_all_subcommands'   s    
z#NetCmdTestCase.iter_all_subcommandsN)r   )r
   
__module____qualname__r   r$   r   r   r   r   r      s   

r   c                   @   s   e Zd Zdd ZdS )TestParmTestsc                 C   s2   | j tdgdd\}}| d| | d| d S )Nz--client-name=foo)r    zPERROR: Both a DNS name and an IP address are required for the host access check
)r   r   r   )r   outerrr   r   r   test_no_client_ip3   s    

zTestParmTests.test_no_client_ipN)r
   r%   r&   r,   r   r   r   r   r'   1   s   r'   c                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
CommandTestsc                 C   s$   G dd dt }| d| j d S )Nc                   @   s   e Zd ZdZdS )z.CommandTests.test_description.<locals>.cmd_fooMydescriptionN)r
   r%   r&   __doc__r   r   r   r   cmd_foo?   s   r0   r.   )r   r   short_descriptionr   r0   r   r   r   test_description>   s    zCommandTests.test_descriptionc                 C   s$   G dd dt }| d| j d S )Nc                   @   s   e Zd ZdS )z'CommandTests.test_name.<locals>.cmd_fooN)r
   r%   r&   r   r   r   r   r0   D   s   r0   Zfoo)r   r   namer2   r   r   r   	test_nameC   s    zCommandTests.test_namec                 C   s@   g }|   D ]\}}|jd u r|| q|r<| d|  d S )Nz5The following commands do not have a synopsis set: %r)r$   Zsynopsisappendfailr   Zmissingr   r   r   r   r   test_synopsis_everywhereH   s    
z%CommandTests.test_synopsis_everywherec                 C   sD   g }|   D ]\}}|jd u r|| q|s2d S | d|  d S )Nz>The following commands do not have a short description set: %r)r$   r1   r6   r7   r8   r   r   r   !test_short_description_everywhereQ   s    
z.CommandTests.test_short_description_everywhereN)r
   r%   r&   r3   r5   r9   r:   r   r   r   r   r-   <   s   	r-   )r/   Zsamba.compatr   Zsamba.netcmdr   Zsamba.netcmd.testparmr   Zsamba.netcmd.mainr   Zsamba.testsZsambaZtestsZTestCaser   r'   r-   r   r   r   r   <module>   s   