Skip to main content
Glama

MCP Weather Server

test_server.cpython-312-pytest-7.4.4.pyc9.79 kB
� ���h���l�ddlZddlmcmZddlZddlmZddl m Z ee �Z d�Z d�Z d�Zd�Zd�Zy) �N)� TestClient)�appc ��tjddddddd�d�� �}|j}d }||k(}|s�tjd |fd ||f�d t j �vstj|�rtj|�nd tj|�tj|�d�z}dd|iz}ttj|���dx}x}}d}|j}|�}||v}|s�tjd|fd||f�tj|�d t j �vstj|�rtj|�nd tj|�tj|�d�z}dd|iz} ttj| ���dx}x}x}}y)N�/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�py7�daily��in�zC%(py1)s in %(py7)s {%(py7)s = %(py5)s {%(py5)s = %(py3)s.json }() }��py1�py3rr�assert %(py9)s�py9� �client�post� status_code� @pytest_ar�_call_reprcompare� @py_builtins�locals�_should_repr_global_name� _saferepr�AssertionError�_format_explanationr� r� @py_assert1� @py_assert4� @py_assert3� @py_format6� @py_format8� @py_assert0� @py_assert6� @py_assert2� @py_format10s �/app/test_server.py�test_get_weather_forecastr?s����{�{�6�&��!��#�  �)�{��H�'�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�c��tjddddd�d���}|j}d}||k(}|s�tjd |fd ||f�d t j �vstj|�rtj|�nd tj|�tj|�d �z}d d|iz}ttj|���dx}x}}d}|j}|�}||v}|s�tjd|fd||f�tj|�d t j �vstj|�rtj|�nd tj|�tj|�d�z}dd|iz} ttj| ���dx}x}x}}y)Nr�get_current_weather���(\�BJ@�R����*@)r r rrrrrrrrr�current_weatherr r"r#r&r'r(r4s r>�test_get_current_weatherrFs����{�{�6�%��� �)�{��H�'�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/r@c ��tjddddddd�d�� �}|j}d }||k(}|s�tjd |fd ||f�d t j �vstj|�rtj|�nd tj|�tj|�d�z}dd|iz}ttj|���dx}x}}d}|j}|�}||v}|s�tjd|fd||f�tj|�d t j �vstj|�rtj|�nd tj|�tj|�d�z}dd|iz} ttj| ���dx}x}x}}y)Nr�get_historical_weatherrCrDz 2023-01-01z 2023-01-02)r r � start_date�end_daterrrrrrrrrrr r"r#r&r'r(r4s r>�test_get_historical_weatherrKs����{�{�6�(���&�$�  �)�{��H�'�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%r@c��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�rrrrrr�detailzTool not found)zC%(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.json }() } == %(py7)s)rr�py4rr&r'r() rr5r6r7r8r9r;� @py_assert5r=s r>�test_tool_not_foundrQ,s����{�{�6��r�(R�{�S�H�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�:�:�:�:�:�:�:�:�:�:�:�:�:�:�:�:�:�:�:�:�:�:�:�:�:�:�:�:�:r@c�:���Gd�d��G�fd�d���fd�}|jd|�|jdd�tjd d d d d dgd�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)�selfrXs r>�__init__z7test_predict_weather_alert.<locals>.MockChoice.__init__3s���D�L�"�D�Lr@N��__name__� __module__� __qualname__rZ�r@r>� MockChoicerT2s�� #r@r`c���eZdZ�fd�Zy)�2test_predict_weather_alert.<locals>.MockCompletionc�"���|�g|_yrV)�choices)rYrXr`s �r>rZz;test_predict_weather_alert.<locals>.MockCompletion.__init__8s���&�w�/�0�D�Lr@Nr[)r`s�r>�MockCompletionrb7s��� 1r@rec����d�S)N�!Sunny with a chance of meatballs.r_)�args�kwargsres �r>� mock_createz/test_predict_weather_alert.<locals>.mock_create;s����A�B�Br@z4openai.resources.chat.completions.Completions.create�OPENAI_API_KEY�test_keyr�predict_weather_alertrr �wheat�corn)r r �cropsrrrrrrrrr�alertr r"r#r&r'rg)z%(py1)s == %(py4)s)r$rOzassert %(py6)s�py6)�setattr�setenvr)r*r+r,r-r.r/r0r1r2r3r)� monkeypatchrjrr5r6r7r8r9r:r;r<r=� @py_format5� @py_format7r`res @@r>�test_predict_weather_alertrx1sI���#�#� 1�1�C����N�P[�\����'��4��{�{�6�'��!��v�&� �)�{��H�'�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�&�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�J�J�J�J�J�J�J�J�J�J�J�J�J�J�J�J�J�Jr@)�builtinsr.�_pytest.assertion.rewrite� assertion�rewriter,�pytest�fastapi.testclientr�src.mcp_weather_server.serverrr)r?rFrKrQrxr_r@r>�<module>r�s5���� �)�-� �C��� &� 0� &�;� Kr@

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