HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/samba/tests/__pycache__/netcmd.cpython-310.pyc
o

�/aL�@s�dZddlZddlZddlmZddlmZddlmZddl	m
Z
ddlZGdd�dej
j�ZGd	d
�d
e�ZGdd�de�ZdS)
zTests for samba.netcmd.�N)�StringIO)�Command)�cmd_testparm)�
cmd_sambatoolc@seZdZddd�Zdd�ZdS)�NetCmdTestCaserc
Cs||t�t�d�}z|j|jg|�R�}Wnty-}z
|�|�d}WYd}~nd}~ww|�||�|j��|j��fS)N)�outf�errf�)	r�_run�__name__�	Exception�show_command_error�assertEqualr�getvaluer)�self�	cmd_klass�args�retcode�cmd�retval�e�r�4/usr/lib/python3/dist-packages/samba/tests/netcmd.py�
run_netcmd s
��zNetCmdTestCase.run_netcmdc#s^�ttj���}|r-|��\�}�|fVt|di�}|��fdd�|��D��|s
dSdS)N�subcommandscs g|]\}}�d||f�qS)� r)�.0�k�v��pathrr�
<listcomp>0s z7NetCmdTestCase.iter_all_subcommands.<locals>.<listcomp>)�listrr�items�pop�getattr�extend)r�todor�subcmdsrrr�iter_all_subcommands*s�
��z#NetCmdTestCase.iter_all_subcommandsN)r)r�
__module__�__qualname__rr)rrrrrs

rcsDeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Z�Z	S)
�
TestParmTestscst���d}|�|�|_dS)Nz[[global]
    netbios name = test
    lock dir = /
    pid directory = /
[tmp]
    path = /
)�super�setUp�create_smbconf�smbconf)r�contents��	__class__rrr.6s
zTestParmTests.setUpcCsFtjd|jdd�}|�tj|j�z|�|�W|��|S|��w)N�wF)�mode�dir�delete)	�tempfile�NamedTemporaryFile�tempdir�
addCleanup�os�remove�name�write�close)rr1r0rrrr/Ds�
�zTestParmTests.create_smbconfcCs2|jtdgdd�\}}|�d|�|�d|�dS)Nz--client-name=foo����r�zPERROR: Both a DNS name and an IP address are required for the host access check
)rrr�r�out�errrrr�test_no_client_ipQs

��zTestParmTests.test_no_client_ipcCs |jtd|jjdgdd�dS)N�--configfile=%s�--section-name=tmprB)rrr0r>)rrrr�test_sectionYs
�
�zTestParmTests.test_sectioncCsv|jtd|jjdgdd�\}}|�d|�|�d|�|jtd|jjddgdd�\}}|�d|�|�d|�dS)NrHz--section-name=foorArBrC�uncaught exception�--parameter-name=foo�rrr0r>r�assertNotInrDrrr�test_no_such_sectionas"
�
�
�
�z"TestParmTests.test_no_such_sectioncCs>|jtd|jjddgdd�\}}|�d|�|�d|�dS)NrHrIrLrArBrCrKrMrDrrr�test_no_such_parameterss
�
�z$TestParmTests.test_no_such_parameter)
rr*r+r.r/rGrJrOrP�
__classcell__rrr2rr,4s
r,c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�CommandTestscC�$Gdd�dt�}|�d|�j�dS)Nc@seZdZdZdS)z.CommandTests.test_description.<locals>.cmd_foo�
MydescriptionN)rr*r+�__doc__rrrr�cmd_foo�srVrT)rr�short_description�rrVrrr�test_description��zCommandTests.test_descriptioncCrS)Nc@seZdZdS)z'CommandTests.test_name.<locals>.cmd_fooN)rr*r+rrrrrV�srV�foo)rrr>rXrrr�	test_name�rZzCommandTests.test_namecCsDg}|��D]\}}|jdur|�|�q|r |�d|�dSdS)Nz5The following commands do not have a synopsis set: %r)r)�synopsis�append�fail�r�missingr rrrr�test_synopsis_everywhere�s

�
��z%CommandTests.test_synopsis_everywherecCsDg}|��D]\}}|jdur|�|�q|sdS|�d|�dS)Nz>The following commands do not have a short description set: %r)r)rWr^r_r`rrr�!test_short_description_everywhere�s

���z.CommandTests.test_short_description_everywhereN)rr*r+rYr\rbrcrrrrrR~s
	rR)rUr<r8�ior�samba.netcmdr�samba.netcmd.testparmr�samba.netcmd.mainr�samba.tests�samba�tests�TestCaseInTempDirrr,rRrrrr�<module>sJ