Skip to main content
Glama

MCP Weather Server

test_server.cpython-312-pytest-8.4.1.pyc11.7 kB
� ��h� ��l�ddlZddlmcmZddlZddlmZddl m Z ee �Z d�Z d�Z d�Zd�Zd�Zy) �N)� TestClient)�appc ���d�}|jd|�tjddddddd �d �� �}|j}d }||k(}|s�t j d |fd||f�dt j�vst j|�rt j|�ndt j|�t j|�d�z}dd|iz}tt j|���dx}x}}d}|j}|�} || v} | s�t j d| fd|| f�t j|�dt j�vst j|�rt j|�ndt j|�t j| �d�z}dd|iz} tt j| ���dx}x} x}} y)Nc��K�ddiS�w�N�daily�mocked_forecast���args�kwargss �/app/test_server.py�mock_get_weather_forecastz<test_get_weather_forecast.<locals>.mock_get_weather_forecast������*�+�+����<src.mcp_weather_server.tools.open_meteo.get_weather_forecast�/mcp�get_weather_forecast�^K�=[D@���Mb�R��F)�latitude� longitude�days�include_hourly��tool� parameters��json����==�z3%(py2)s {%(py2)s = %(py0)s.status_code } == %(py5)s�response��py0�py2�py5�assert %(py7)s�py7r��in�zC%(py1)s in %(py7)s {%(py7)s = %(py5)s {%(py5)s = %(py3)s.json }() }��py1�py3r)r+�assert %(py9)s�py9� �setattr�client�post� status_code� @pytest_ar�_call_reprcompare� @py_builtins�locals�_should_repr_global_name� _saferepr�AssertionError�_format_explanationr ) � monkeypatchrr%� @py_assert1� @py_assert4� @py_assert3� @py_format6� @py_format8� @py_assert0� @py_assert6� @py_assert2� @py_format10s r�test_get_weather_forecastrKs9��,����V�Xq�r��{�{�6�&��!��#�  �)�{��H� � � �&�3�&� �3� &�&�&�&� �3�&�&�&�&�&�&�8�&�&�&�8�&�&�&� �&�&�&�3�&�&�&�&�&�&�&� �%�h�m�m�%�m�o�%�7�o� %�%�%�%�7�o�%�%�%�7�%�%�%�%�%�%�h�%�%�%�h�%�%�%�m�%�%�%�o�%�%�%�%�%�%�%�c���d�}|jd|�tjddddd�d�� �}|j}d }||k(}|s�t j d |fd ||f�d t j�vst j|�rt j|�nd t j|�t j|�d�z}dd|iz}tt j|���dx}x}}d}|j}|�} || v} | s�t j d| fd|| f�t j|�d t j�vst j|�rt j|�nd t j|�t j| �d�z}dd|iz} tt j| ���dx}x} x}} y)Nc��K�ddiS�w)N�current_weather�mocked_weatherr r s r�mock_get_current_weatherz:test_get_current_weather.<locals>.mock_get_current_weathers����!�#3�4�4�rz;src.mcp_weather_server.tools.open_meteo.get_current_weatherr�get_current_weather���(\�BJ@�R����*@)rrrrr!r"r$r%r&r*r+rOr,r.r/r2r3r4) rArQr%rBrCrDrErFrGrHrIrJs r�test_get_current_weatherrUs6��5����U�Wo�p��{�{�6�%��� �)�{��H� � � �&�3�&� �3� &�&�&�&� �3�&�&�&�&�&�&�8�&�&�&�8�&�&�&� �&�&�&�3�&�&�&�&�&�&�&� �/�� � �/� ��/� �� /�/�/�/� ��/�/�/� �/�/�/�/�/�/��/�/�/��/�/�/� �/�/�/��/�/�/�/�/�/�/rLc ���d�}|jd|�tjddddddd �d �� �}|j}d }||k(}|s�t j d |fd||f�dt j�vst j|�rt j|�ndt j|�t j|�d�z}dd|iz}tt j|���dx}x}}d}|j}|�} || v} | s�t j d| fd|| f�t j|�dt j�vst j|�rt j|�ndt j|�t j| �d�z}dd|iz} tt j| ���dx}x} x}} y)Nc��K�ddiS�w)Nr�mocked_historicalr r s r�mock_get_historical_weatherz@test_get_historical_weather.<locals>.mock_get_historical_weather(s�����,�-�-�rz>src.mcp_weather_server.tools.open_meteo.get_historical_weatherr�get_historical_weatherrSrTz 2023-01-01z 2023-01-02)rr� start_date�end_daterrr!r"r$r%r&r*r+rr,r.r/r2r3r4) rArYr%rBrCrDrErFrGrHrIrJs r�test_get_historical_weatherr]'s9��.����X�Zu�v��{�{�6�(���&�$�  �)�{��H� � � �&�3�&� �3� &�&�&�&� �3�&�&�&�&�&�&�8�&�&�&�8�&�&�&� �&�&�&�3�&�&�&�&�&�&�&� �%�h�m�m�%�m�o�%�7�o� %�%�%�%�7�o�%�%�%�7�%�%�%�%�%�%�h�%�%�%�h�%�%�%�m�%�%�%�o�%�%�%�%�%�%�%rLc��tjddid���}|j}d}||k(}|s�tjd|fd||f�dt j �vstj|�rtj|�ndtj|�tj|�d �z}d d |iz}ttj|���dx}x}}|j}|�}d d i}||k(}|s�tjd|fd||f�dt j �vstj|�rtj|�ndtj|�tj|�tj|�d�z}dd|iz}ttj|���dx}x}x}}y)Nr� invalid_toolrri�r"r$r%r&r*r+�detailzTool not found)zC%(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.json }() } == %(py7)s)r'r(�py4r+r2r3) r6r7r8r9r:r;r<r=r>r?r@r ) r%rBrCrDrErFrH� @py_assert5rJs r�test_tool_not_foundrc8s���{�{�6��r�(R�{�S�H� � � �&�3�&� �3� &�&�&�&� �3�&�&�&�&�&�&�8�&�&�&�8�&�&�&� �&�&�&�3�&�&�&�&�&�&�&� �=�=�:�=�?�:�x�)9�:�:�?�:� :�:�:�:�?�:�:�:�:�:�:�:�8�:�:�:�8�:�:�:�=�:�:�:�?�:�:�:�:�:�:�:�:�:�:�:rLc�d���Gd�d��G�fd�d���fd�}d�}|jd|�|jd|�|jd d �tjd d d dddgd�d���}|j}d}||k(}|s�t j d|fd||f�dtj�vst j|�rt j|�ndt j|�t j|�d�z}dd|iz}tt j|���dx}x}}d} |j}|�} | | v} | s�t j d| fd| | f�t j| �dtj�vst j|�rt j|�ndt j|�t j| �d�z}dd |iz} tt j| ���dx} x} x}} |j�d} d!}| |k(} | slt j d| fd"| |f�t j| �t j|�d#�z} d$d%| iz}tt j|���dx} x} }y)&Nc��eZdZd�Zy)�.test_predict_weather_alert.<locals>.MockChoicec� �||_||_y�N)�message�content)�selfrjs r�__init__z7test_predict_weather_alert.<locals>.MockChoice.__init__?s���D�L�"�D�LrLN��__name__� __module__� __qualname__rlr rLr� MockChoicerf>s�� #rLrqc���eZdZ�fd�Zy)�2test_predict_weather_alert.<locals>.MockCompletionc�"���|�g|_yrh)�choices)rkrjrqs �rrlz;test_predict_weather_alert.<locals>.MockCompletion.__init__Ds���&�w�/�0�D�LrLNrm)rqs�r�MockCompletionrsCs��� 1rLrvc����d�S)N�!Sunny with a chance of meatballs.r )r r rvs �r� mock_createz/test_predict_weather_alert.<locals>.mock_createGs����A�B�BrLc��K�ddiS�wrr r s rrz=test_predict_weather_alert.<locals>.mock_get_weather_forecastJrrrz4openai.resources.chat.completions.Completions.create�OPENAI_API_KEY�test_keyr�predict_weather_alertrr�wheat�corn)rr�cropsrrr!r"r$r%r&r*r+�alertr,r.r/r2r3rx)z%(py1)s == %(py4)s)r0razassert %(py6)s�py6)r5�setenvr6r7r8r9r:r;r<r=r>r?r@r )rAryrr%rBrCrDrErFrGrHrIrJ� @py_format5� @py_format7rqrvs @@r�test_predict_weather_alertr�=s����#�#� 1�1�C�,����V�Xq�r����N�P[�\����'��4��{�{�6�'��!��v�&� �)�{��H� � � �&�3�&� �3� &�&�&�&� �3�&�&�&�&�&�&�8�&�&�&�8�&�&�&� �&�&�&�3�&�&�&�&�&�&�&� �%�h�m�m�%�m�o�%�7�o� %�%�%�%�7�o�%�%�%�7�%�%�%�%�%�%�h�%�%�%�h�%�%�%�m�%�%�%�o�%�%�%�%�%�%�%� �=�=�?�7� #�J�'J�J� #�'J� J�J�J�J� #�'J�J�J�J� #�J�J�J�'J�J�J�J�J�J�J�JrL)�builtinsr;�_pytest.assertion.rewrite� assertion�rewriter9�pytest�fastapi.testclientr�src.mcp_weather_server.serverrr6rKrUr]rcr�r rLr�<module>r�s5���� �)�-� �C���&�" 0�&�";� KrL

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/digitalgreenorg/AgMCP'

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