관리-도구
편집 파일: test_applications.cpython-39.opt-1.pyc
a ����"e�����������������������@���s����d�dl�T�ddlmZ�ddlmZmZ�ddlmZmZ�zddl m Z mZ�dZW�n ���ddl m Z mZ�dZY�n0�G�d d ��d ej�Zedkr�e����dS�) ����)�*�����)�DATA_DIR)�Applications�Application)�ApplicationsCollection�ProcessesCollection)�patch� mock_openz builtins.openz__builtin__.openc�������������������@���s����e�Zd�Zedd���Zdd��Zdd��Zdd��Zd d ��Zdd��Z e d dd�dd���Zdd��Zdd��Z dd��Zdd��Ze ddd�dd���Zdd��Zd S�)!�TestApplicationsc�����������������C���s���dd��t�jD��|�_d�S�)Nc�����������������S���s���g�|�]}|��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���� setUpClass���s����zTestApplications.setUpClassc�����������������C���s���|�j�t_�d�t_d�S��N)r���r���Z_apps��selfr���r���r����setUp���s����zTestApplications.setUpc�����������������C���s���|���t���t��d�S�r���)�assertIsInstancer����allr���r���r���r���r����test_apps_types���s����z TestApplications.test_apps_typesc�����������������C���s���t����d�}|��|jt��d�S�)Nr���)r���r���r���Z instancesr���)r����applicationr���r���r����test_application_processes���s����z+TestApplications.test_application_processesc�����������������C���s����d}t����D�]�}d|vs$t|�dkr6|��dt|����d|v�r^|jt�j���vr^|��d|j���d|v�rjdnd}|��t|�|d � |j ���|d7�}qd�S�) Nr����namezMissing name in definition #�typezUnknown type in application: �rename���������)Application {0} has unsupported attribute)r���r����len�fail�strr ���ZTYPES�values�assertEqual�formatr���)r����i�a�nr���r���r����test_apps_attributes ���s����z%TestApplications.test_apps_attributesc�����������������C���s8���t����}|D�]&}|��|j|�dkr|��d|j���qd�S�)Nr���zDuplicate definitions for: )r���r����_countr���r&���)r����appsr,���r���r���r����test_apps_duplicity.���s����z$TestApplications.test_apps_duplicityz0tracer.resources.applications.System.init_systemZdummy)Zreturn_valuec�����������������C���sf���d}t��|�}|��|j|��|��|jt�j��|��|jd���|��|jd���|��t|�dd� |j���d�S�)NZNON_EXISTING_APPLICATIONr#���r$���) r����findr)���r���r ���ZDEFAULT_TYPE�helperZnoter%���r*���)r���Zinit_system�app_nameZappr���r���r����test_app_with_no_definition4���s���� z,TestApplications.test_app_with_no_definitionc�����������������C���s0���t�ddi�}|��t|�d��|��t|�d��d�S�)Nr����fooz<Application: foo>)r���r)���r'����repr)r���Zruler���r���r����test_representations>���s����z%TestApplications.test_representationsc�����������������C���s<���t�dddd��}t�dddd��}|��|j��|��|j��d�S�)Nr6����applicaiton�some helper�r���r ���r3���r���z some helper with {NAME} argument)r����assertFalse�helper_contains_name� assertTrue)r����a1Za2r���r���r����test_contains_nameC���s����z#TestApplications.test_contains_namec�����������������C���s<���t�dddd��}t�dddd��}|��|j��|��|j��d�S�)Nr6���r9���r:���r;���r���zsome helper with {FOO} argument)r���r<����helper_contains_formatingr>���)r���r?����a3r���r���r����test_contains_formatingI���s����z(TestApplications.test_contains_formatingc�����������������C���s,���t�ddd�d��}|��|j��|��|j��d�S�)Nr6���r9���r;���)r���r<���rA���r=���)r���r?���r���r���r����test_helper_contains_when_noneO���s����z/TestApplications.test_helper_contains_when_nonez*tracer.resources.system.System.init_systemZsystemdc�����������������C���s����dgt�_d}ttt|d�����t����}|��t|�d��|��tdd��|D�����|��|d�j d��|��|d�j �d ���|��|d �jd��|�� d|d �j ��W�d ����n1�s�0����Y��d 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����c�����������������S���s���g�|�]}t�|t��qS�r���)� isinstancer���r���r���r���r���r���f��������z.TestApplications.test_load.<locals>.<listcomp>r���r6���zsystemctl restart foo����Zsessionzkill itN)r���r���r ���� builtins_openr ���r���r)���r%���r>���r���r3����endswithr ���ZassertIn)r���Z_init_system�datar0���r���r���r���� test_loadT���s����� zTestApplications.test_loadc�����������������C���s$���d}|D�]}|j�|kr|d7�}q|S�)Nr���r���)r���)r���r4���r0����countr,���r���r���r���r/���l���s ���� zTestApplications._countN)�__name__� __module__�__qualname__�classmethodr���r���r���r���r.���r1���r ���r5���r8���r@���rC���rD���rL���r/���r���r���r���r���r������s ��� r����__main__N)Z__meta__Ztracer.pathsr���Ztracer.resources.applicationsr���r���Ztracer.resources.collectionsr���r���Z unittest.mockr ���r ���rI���ZmockZunittestZTestCaser���rN����mainr���r���r���r����<module>���s��� f