
    b                         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Z G d dej        j                  Z G d	 d
e          Z G d de          ZdS )zTests for samba.netcmd.    N)StringIO)Command)cmd_testparm)cmd_sambatoolc                       e Zd ZddZd ZdS )NetCmdTestCaser   c                 b    |t                      t                                }	  |j        |j        g|R  }n.# t          $ r!}|                    |           d}Y d }~nd }~ww xY w|                     ||           |j                                        |j                                        fS )N)outferrf   )	r   _run__name__	Exceptionshow_command_errorassertEqualr
   getvaluer   )self	cmd_klassargsretcodecmdretvales          4/usr/lib/python3/dist-packages/samba/tests/netcmd.py
run_netcmdzNetCmdTestCase.run_netcmd    s    iXZZhjj999	SXi084888FF 	 	 	""1%%%FFFFFF	 	&)))x  ""CH$5$5$7$777s   ; 
A&A!!A&c              #   0  K   t          t          j                                                  }|re|                                \  }|fV  t          |di           }|                    fd|                                D                        |cd S d S )Nsubcommandsc                 *    g | ]\  }}d z   |z   |fS )  ).0kvpaths      r   
<listcomp>z7NetCmdTestCase.iter_all_subcommands.<locals>.<listcomp>0   s6     * * *!Q$*q.!, * * *    )listr   r   itemspopgetattrextend)r   todor   subcmdsr$   s       @r   iter_all_subcommandsz#NetCmdTestCase.iter_all_subcommands*   s      M-335566 	+((**KT3)OOOc="55GKK * * * * * * * + + +	  	+ 	+ 	+ 	+ 	+r&   N)r   )r   
__module____qualname__r   r.   r    r&   r   r   r      s7        8 8 8 8+ + + + +r&   r   c                   B     e Zd Z fdZd Zd Zd Zd Zd Zd Z	 xZ
S )TestParmTestsc                     t                                                       d}|                     |          | _        d S )Nz[[global]
    netbios name = test
    lock dir = /
    pid directory = /
[tmp]
    path = /
)supersetUpcreate_smbconfsmbconf)r   contents	__class__s     r   r5   zTestParmTests.setUp6   s6     **844r&   c                    t          j        d| j        d          }|                     t          j        |j                   	 |                    |           |                                 n# |                                 w xY w|S )NwF)modedirdelete)	tempfileNamedTemporaryFiletempdir
addCleanuposremovenamewriteclose)r   r8   r7   s      r   r6   zTestParmTests.create_smbconfD   sz    -326,5:< < < 		7<000	MM(###MMOOOOGMMOOOOs   A- -Bc                     |                      t          dg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errs      r   test_no_client_ipzTestParmTests.test_no_client_ipQ   si    ??<2E1F+- # / /SS!!!347	9 	9 	9 	9 	9r&   c                 ^    |                      t          d| j        j        z  dgd            d S )N--configfile=%s--section-name=tmprJ   r   r   r7   rE   )r   s    r   test_sectionzTestParmTests.test_sectionY   sC     	*T\->>-/ $ 	 	& 	& 	& 	& 	&r&   c                 n    dD ]1}|                      t          d| j        j         d| gd            2d S )N)globalglobalsz--configfile=z--section-name=rJ   rS   )r   rE   s     r   test_section_globalsz"TestParmTests.test_section_globalsa   s`    ) 	* 	*DOOL@T\->@@5t557$(  * * * *	* 	*r&   c                 t   |                      t          d| j        j        z  dgd          \  }}|                     d|           |                     d|           |                      t          d| j        j        z  ddgd          \  }}|                     d|           |                     d|           d S )NrQ   z--section-name=foorI   rJ   rK   uncaught exception--parameter-name=foor   r   r7   rE   r   assertNotInrL   s      r   test_no_such_sectionz"TestParmTests.test_no_such_sectioni   s    ??<$58I$I$8$:+- # / /S
 	S!!!-s333??<$58I$I$8$:$< ,.	 # / /S 	S!!!-s33333r&   c                     |                      t          d| j        j        z  ddgd          \  }}|                     d|           |                     d|           d S )NrQ   rR   r[   rI   rJ   rK   rZ   r\   rL   s      r   test_no_such_parameterz$TestParmTests.test_no_such_parameter{   sr    ??<$58I$I$8$:$< ,.	 # / /S 	S!!!-s33333r&   )r   r/   r0   r5   r6   rO   rT   rX   r^   r`   __classcell__)r9   s   @r   r2   r2   4   s        5 5 5 5 5  9 9 9& & &* * *4 4 4$4 4 4 4 4 4 4r&   r2   c                   &    e Zd Zd Zd Zd Zd ZdS )CommandTestsc                 r     G d dt                     }|                     d |            j                   d S )Nc                       e Zd ZdZdS ).CommandTests.test_description.<locals>.cmd_fooMydescriptionN)r   r/   r0   __doc__r    r&   r   cmd_foorf      s        r&   ri   rg   )r   r   short_descriptionr   ri   s     r   test_descriptionzCommandTests.test_description   sQ    	  	  	  	  	 g 	  	  	 ''))*EFFFFFr&   c                 r     G d dt                     }|                     d |            j                   d S )Nc                       e Zd ZdS )'CommandTests.test_name.<locals>.cmd_fooN)r   r/   r0   r    r&   r   ri   ro      s        Dr&   ri   foo)r   r   rE   rk   s     r   	test_namezCommandTests.test_name   sP    	 	 	 	 	g 	 	 			/////r&   c                     g }|                                  D ]!\  }}|j        |                    |           "|r|                     d|z             d S d S )Nz5The following commands do not have a synopsis set: %r)r.   synopsisappendfailr   missingr$   r   s       r   test_synopsis_everywherez%CommandTests.test_synopsis_everywhere   s~    2244 	% 	%ID#|#t$$$ 	IIM     	 	r&   c                     g }|                                  D ]!\  }}|j        |                    |           "|sd S |                     d|z             d S )Nz>The following commands do not have a short description set: %r)r.   rj   rt   ru   rv   s       r   !test_short_description_everywherez.CommandTests.test_short_description_everywhere   sz    2244 	% 	%ID#$,t$$$ 	F		L	 	 	 	 	r&   N)r   r/   r0   rl   rq   rx   rz   r    r&   r   rc   rc      sS        G G G
0 0 0
  	 	 	 	 	r&   rc   )rh   rC   r?   ior   samba.netcmdr   samba.netcmd.testparmr   samba.netcmd.mainr   samba.testssambatestsTestCaseInTempDirr   r2   rc   r    r&   r   <module>r      s	  $   				                    . . . . . . + + + + + +    + + + + +U[2 + + +,O4 O4 O4 O4 O4N O4 O4 O4d    >     r&   