Skip to main content
Glama
test_libvirt_connection_pool.cpython-313-pytest-8.3.5.pyc13.6 kB
� �@h� ���SSKrSSKJs Jr SSKrSSKrSSKrSSK J r J r SSK J r \RRS5r\RRS5r\RRS5r\RRS5r\RRS5r\RRS 5rg) �N)�patch� MagicMock)�LibvirtConnectionPoolc ��# �[S5n[5nXl[SS9nURnSoCU:HoU(d�[ R "SU4SX445S[R"5;d[ R"U5(a[ R"U5OS[ R"U5[ R"U5S.-nSS U0-n[[ R"U55eS =n=pTURo3RoU"5nSo�U :Ho�(d�[ R "SU 4S X�45S[R"5;d[ R"U5(a[ R"U5OS[ R"U5[ R"U5[ R"U5[ R"U 5S .-n S SU 0-n [[ R"U 55eS =n=n=n=p�URnSoCU:HoU(d�[ R "SU4SX445S[R"5;d[ R"U5(a[ R"U5OS[ R"U5[ R"U5S.-nSS U0-n[[ R"U55eS =n=pTS S S 5 g !,(df  g =f7f)z.Test the initialization of the connection pool� libvirt.open���max_connections��==�z:%(py2)s {%(py2)s = %(py0)s.active_connections } == %(py5)s�pool��py0�py2�py5�assert %(py7)s�py7N)ze%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.connections }.qsize }() } == %(py9)s)rr�py4�py6�py9zassert %(py11)s�py11�z2%(py2)s {%(py2)s = %(py0)s.call_count } == %(py5)s� mock_open)rr� return_valuer�active_connections� @pytest_ar�_call_reprcompare� @py_builtins�locals�_should_repr_global_name� _saferepr�AssertionError�_format_explanation� connections�qsize� call_count) r� mock_connr� @py_assert1� @py_assert4� @py_assert3� @py_format6� @py_format8� @py_assert5� @py_assert8� @py_assert7� @py_format10� @py_format12s �B/home/steve/projects/kvm-mcp/tests/test_libvirt_connection_pool.py�#test_connection_pool_initializationr4s���� �~� �)��K� �!*��$�Q�7���&�&�+�!�+�!�+�+�+�+�+�&�+�+�+�+�+�+�t�+�+�+�+�t�+�+�+�&�+�+�+�!�+�+�+�+�+�+�+����,�%�%�,�%�'�,�1�,�1�,�,�,�,�,�'�,�,�,�,�,�,�t�,�,�,�,�t�,�,�,��,�,�,�%�,�,�,�'�,�,�,�1�,�,�,�,�,�,�,��#�#�(�q�(�q�(�(�(�(�(�#�(�(�(�(�(�(�y�(�(�(�(�y�(�(�(�#�(�(�(�q�(�(�(�(�(�(�(� � � �s� L�KK5�, L�5 L�?Lc ��# �[S5n[5nXl[SS9nUR 5IShv�N nX1:HoD(d�[ R "SU4SX145S[R"5;d[ R"U5(a[ R"U5OSS[R"5;d[ R"U5(a[ R"U5OSS .-nS S U0-n[[ R"U55eSnURnSotU:Ho�(d�[ R "SU4S XG45S [R"5;d[ R"U5(a[ R"U5OS [ R"U5[ R"U5S.-n SSU 0-n [[ R"U 55eS=n=p�SSS5IShv�N SSS5 gGN�N!,IShv�N (df  N%=f!,(df  g=f7f)z'Test getting a connection from the poolr�r Nr �z%(py0)s == %(py2)s�connr(�rr�assert %(py4)srr rrrr)rrrr�get_connectionrrrr r!r"r#r$r� rr(rr8r)� @py_format3� @py_format5r*r+r,r-s r3�#test_connection_pool_get_connectionr?s@��� �~� �)��K� �!*��$�Q�7���&�&�(�(�D��$� $� $� $� $�4� $� $� $� $� $� $�4� $� $� $� $�4� $� $� $� $� $� $�9� $� $� $� $�9� $� $� $� $� $� $� $��*�*� /�a� /�a�/� /� /� /� /�*� /� /� /� /� /� /�4� /� /� /� /�4� /� /� /�*� /� /� /�a� /� /� /� /� /� /� /�)�(� � � )�(�(�(�� � �sc� I�.H7�H�H7�F?H�? H7� H� H7� I�H7�H7�H4 �#H&�$ H4 �0H7�7 I�Ic ��&# �[S5n[5nXl[SSS9nUR 5IShv�N UR 5IShv�N nX1:HoD(d�[ R "SU4SX145S[R"5;d[ R"U5(a[ R"U5OSS [R"5;d[ R"U5(a[ R"U5OS S .-nS S U0-n[[ R"U55eSnURnS otU:Ho�(d�[ R "SU4SXG45S[R"5;d[ R"U5(a[ R"U5OS[ R"U5[ R"U5S.-n SSU 0-n [[ R"U 55eS=n=p�SSS5IShv�N SSS5IShv�N SSS5 gGNGN�N#!,IShv�N (df  N8=fN/!,IShv�N (df  ND=f!,(df  g=f7f)z%Test connection pool timeout behaviorrr6g�������?)r �timeoutNr r7r8r(r9r:rrrrrrr)rrrrr;rrrr r!r"r#r$r'r<s r3�test_connection_pool_timeoutrBsk��� �~� �)��K� �!*��$�Q��D���&�&�(�(��*�*�,�,���(�(�(�(�(�t�(�(�(�(�(�(�t�(�(�(�(�t�(�(�(�(�(�(�y�(�(�(�(�y�(�(�(�(�(�(�(� �+�+�0�q�0�q�0�0�0�0�0�+�0�0�0�0�0�0�y�0�0�0�0�y�0�0�0�+�0�0�0�q�0�0�0�0�0�0�0�-�,�)�(� � � )�,�,�,�,��)�(�(�(�� � �s�� J�/J�I�J�I&�I �I&�F?I � I&�$I�%I&�) J�4I$�5J�9 J�J�I&�I&� I! �I� I! �I&�$J�&I= �,I/�- I= �9J� J� Jc���# �[S5n[5n[R"S5URlXl[SS9nUR5IShv�N SSS5IShv�N URnSoCU:HoU(d�[R"SU4SX445S[R"5;d[R"U5(a[R"U5OS[R"U5[R"U5S .-nS S U0-n[![R""U55eS=n=pTUR$nS oCU:HoU(d�[R"SU4S X445S[R"5;d[R"U5(a[R"U5OS[R"U5[R"U5S .-nS S U0-n[![R""U55eS=n=pTSSS5 gGN�GN�!,IShv�N (df  GN�=f!,(df  g=f7f)z!Test handling of dead connectionsrzConnection deadr6r Nr r rrrrrrr)rr�libvirt� libvirtError� getVersion� side_effectrrr;rrrrr r!r"r#r$r')rr(rr)r*r+r,r-s r3�$test_connection_pool_dead_connectionrH.sc��� �~� �)��K� �+2�+?�+?�@Q�+R� ���(�!*��$�Q�7���&�&�(�(� �)�(��&�&�+�!�+�!�+�+�+�+�+�&�+�+�+�+�+�+�t�+�+�+�+�t�+�+�+�&�+�+�+�!�+�+�+�+�+�+�+��#�#�(�q�(�q�(�(�(�(�(�#�(�(�(�(�(�(�y�(�(�(�(�y�(�(�(�#�(�(�(�q�(�(�(�(�(�(�(� � � )�(�(�(�� � �sf� I �AI�!H.�"I�%H4�' I�2H1�3F2I�% I �.I�1I�4I �:H=�; I �I� I�I c��# �[S5n[5nXl[SS9nUR 5IShv�N UR nSoCU:HoU(d�[ R"SU4SX445S[R"5;d[ R"U5(a[ R"U5OS[ R"U5[ R"U5S .-nS S U0-n[[ R"U55eS=n=pTURo3RoU"5o�(d�S S[R"5;d[ R"U5(a[ R"U5OS[ R"U5[ R"U5[ R"U5S .-n [[ R"U 55eS=n=pXSSS5 gGN�!,(df  g=f7f)z(Test closing all connections in the poolrrr Nrr r rrrrzaassert %(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.connections }.empty }() })rrrr)rrrr� close_allrrrrr r!r"r#r$r%�empty) rr(rr)r*r+r,r-r.� @py_format7s r3�test_connection_pool_close_allrM=s9��� �~� �)��K� �!*��$�Q�7���n�n�����&�&�+�!�+�!�+�+�+�+�+�&�+�+�+�+�+�+�t�+�+�+�+�t�+�+�+�&�+�+�+�!�+�+�+�+�+�+�+����'�%�%�'�%�'�'�'�'�'�'�'�'�'�t�'�'�'�'�t�'�'�'��'�'�'�%�'�'�'�'�'�'�'�'�'�'� � � � � �s-� H �-G:�G7�F2G:�. H �7G:�: H�H c ��X# �[S5n[R"S5Ul[ SS9nUR nSo2U:HoD(d�[ R"SU4SX#45S[R"5;d[ R"U5(a[ R"U5OS[ R"U5[ R"U5S .-nS S U0-n[[ R"U55eS =n=pC[R"[R5 UR!5IS hv�N S S S 5IS hv�N S S S 5 S S S 5 g N&N!,IS hv�N (df  N,=f!,(df  N5=f!,(df  g =f7f) zBTest error handling during initialization and connection retrievalrzConnection failedrr rr r rrrrN)rrDrErGrrrrrr r!r"r#r$�pytest�raisesr;)rrr)r*r+r,r-s r3�#test_connection_pool_error_handlingrQIs���� �~� �)� '� 4� 4�5H� I� ��%�Q�7���&�&�+�!�+�!�+�+�+�+�+�&�+�+�+�+�+�+�t�+�+�+�+�t�+�+�+�&�+�+�+�!�+�+�+�+�+�+�+��]�]�7�/�/� 0��*�*�,�,��-�,�1� � �-�,�,�,��1� 0�� � �s}� F*�D F�.F�E* �F�E.� F�E,�F�F�! F*�*F�,F�.F �4E7�5 F �F� F �F� F'�#F*)�builtinsr�_pytest.assertion.rewrite� assertion�rewriterrO�asynciorD� unittest.mockrr�kvm_mcp_serverr�markr4r?rBrHrMrQ��r3�<module>r\s����� ���*�0������ )�� )������ 0�� 0������ 1�� 1������ )�� )������ (�� (������ �� 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/steveydevey/kvm-mcp'

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