Skip to main content
Glama
test_server_startup.cpython-312-pytest-8.4.1.pyc8.97 kB
� ���hv ��j�dZddlZddlmcmZddlZddlm Z m Z ddl m Z m Z ddlmZGd�d�Zy)z/Tests for MCP server startup and configuration.�N)�patch� MagicMock)�get_job_manager�cleanup_on_shutdown)� JobManagerc��eZdZdZd�Zej jd��Zej jd��Z d�Z d�Z y)�TestServerStartupz&Test server startup and configuration.c�2�ddl}d|j_t�}t |t �}|�s ddt j�vstjt�rtjt�nddt j�vstj|�rtj|�nddt j�vstjt �rtjt �ndtj|�d�z}ttj|���d}t�}||u}|s�tjd|fd ||f�dt j�vstj|�rtj|�ndd t j�vstj|�rtj|�nd d �z}d d |iz}ttj|���d}y)z8Test that get_job_manager creates and returns singleton.rNz5assert %(py4)s {%(py4)s = %(py0)s(%(py1)s, %(py2)s) }� isinstance�manager1r��py0�py1�py2�py4)�is)z%(py0)s is %(py2)s�manager2)rrzassert %(py4)sr)�mcp_background_job.server�server� _job_managerrr r� @py_builtins�locals� @pytest_ar�_should_repr_global_name� _saferepr�AssertionError�_format_explanation�_call_reprcompare)�self�mcp_background_jobr � @py_assert3� @py_format5r� @py_assert1� @py_format3s �W/Users/dylan/Workspace/mcp/servers/mcp-background-job/tests/unit/test_server_startup.py�test_get_job_manager_singletonz0TestServerStartup.test_get_job_manager_singleton s�� )�15��!�!�.�#�$���(�J�/�/�/�/�/�/�/�/�z�/�/�/�z�/�/�/�/�/�/�(�/�/�/�(�/�/�/�/�/�/�J�/�/�/�J�/�/�/�/�/�/�/�/�/�/�#�$���8�#�#�#�#�x�8�#�#�#�#�#�#�x�#�#�#�x�#�#�#�#�#�#�8�#�#�#�8�#�#�#�#�#�#�#�c��K�t�}d�}||_ddl}||j_t ��d{���y7��w)zTest cleanup function.c�� K�y�w)N�r*r'r%� mock_shutdownzATestServerStartup.test_cleanup_on_shutdown.<locals>.mock_shutdown#s ���� �s�rN)r�shutdownrrrr)r� mock_managerr+r s r%�test_cleanup_on_shutdownz*TestServerStartup.test_cleanup_on_shutdowns@����!�{� � �!.� �� )�1=��!�!�.�"�#�#�#�s�7A�?�Ac��^K�ddl}d|j_t��d{���y7��w)z$Test cleanup when no manager exists.rN)rrrr)rr s r%�#test_cleanup_on_shutdown_no_managerz5TestServerStartup.test_cleanup_on_shutdown_no_manager0s(���� )�15��!�!�.�"�#�#�#�s �#-�+�-c��ddlm}gd�}|D�]1}t||�}|�stjd|�d��dzdt j �vstjt�rtjt�nddt j �vstj|�rtj|�ndd t j �vstj|�rtj|�nd tj|�d �z}ttj|���d}��4y) zBTest that all required functions are defined in the server module.rN)� list_jobs�get_job_status�get_job_output�tail_job_output�execute_command�interact_with_job�kill_jobz Function z not found in server modulez7 >assert %(py4)s {%(py4)s = %(py0)s(%(py1)s, %(py2)s) }�hasattr� server_module� func_namer ) rrr9r�_format_assertmsgrrrrrr)rr:�expected_functionsr;r!r"s r%�test_server_functions_existz-TestServerStartup.test_server_functions_exist;s��9� ��,�I��=�)�4� �4� ����I�;�&A�B� � � �v� � ���� � � �I�� � � �v� � ���)� � � �I�)� � � �v� � ���+4� � � �I�+4� � � �I�5� � � ��� � �,r'c��� ddl}|j}d}t||�}|s�ddtj�vst j t�rt jt�nddtj�vst j |�rt j|�ndt j|�t j|�t j|�d�z}tt j|���dx}x}}|j}d}t||�}|s�ddtj�vst j t�rt jt�nddtj�vst j |�rt j|�ndt j|�t j|�t j|�d�z}tt j|���dx}x}}|j}d }t||�}|s�ddtj�vst j t�rt jt�nddtj�vst j |�rt j|�ndt j|�t j|�t j|�d�z}tt j|���dx}x}}|j}d }t||�}|s�ddtj�vst j t�rt jt�nddtj�vst j |�rt j|�ndt j|�t j|�t j|�d�z}tt j|���dx}x}}y#t$r"}tjd |���Yd}~yd}~wwxYw) z.Test that the server module imports correctly.rN�mcpzQassert %(py7)s {%(py7)s = %(py0)s(%(py3)s {%(py3)s = %(py1)s.server }, %(py5)s) }r9r )rr�py3�py5�py7rr�mainz Failed to import server module: ) rrr9rrrrrrr� ImportError�pytest�fail)rr � @py_assert2� @py_assert4� @py_assert6� @py_format8�es r%�test_server_module_importsz,TestServerStartup.test_server_module_importsOs��� @� ,�-�4�4� <�e� <�7�4�e�<� <�<� <� <� <� <� <�7� <� <� <�7� <� <� <� <� <� <�-� <� <� <�-� <� <� <�4� <� <� <�e� <� <� <�<� <� <� <� <� <� <�-�4�4� H�6G� H�7�4�6G�H� H�H� H� H� H� H� H�7� H� H� H�7� H� H� H� H� H� H�-� H� H� H�-� H� H� H�4� H� H� H�6G� H� H� H�H� H� H� H� H� H� H�-�4�4� L�6K� L�7�4�6K�L� L�L� L� L� L� L� L�7� L� L� L�7� L� L� L� L� L� L�-� L� L� L�-� L� L� L�4� L� L� L�6K� L� L� L�L� L� L� L� L� L� L�-�4�4� =�f� =�7�4�f�=� =�=� =� =� =� =� =�7� =� =� =�7� =� =� =� =� =� =�-� =� =� =�-� =� =� =�4� =� =� =�f� =� =� =�=� =� =� =� =� =� =��� @� �K�K�:�1�#�>� ?� ?�� @�s�P4P7�7 Q"�Q�Q"N) �__name__� __module__� __qualname__�__doc__r&rF�mark�asyncior.r0r>rMr*r'r%r r sQ��0� $� �[�[���$��$�& �[�[���$��$��( @r'r )rQ�builtinsr�_pytest.assertion.rewrite� assertion�rewriterrF� unittest.mockrrrrr�mcp_background_job.servicerr r*r'r%�<module>rZs&��5��� �*�J�1�O@�O@r'

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dylan-gluck/mcp-background-job'

If you have feedback or need assistance with the MCP directory API, please join our Discord server