File tree Expand file tree Collapse file tree 4 files changed +99
-0
lines changed
actions/python-build-env-setup Expand file tree Collapse file tree 4 files changed +99
-0
lines changed Original file line number Diff line number Diff line change 1+ name : ' Common Python job setup'
2+ description : ' Perform build environment setup steps common to all Python jobs.'
3+
4+ inputs :
5+ python-version :
6+ description : ' Python version to use'
7+ required : true
8+ default : " 3.13"
9+
10+ runs :
11+ using : " composite"
12+ steps :
13+ - name : Fetch git tags
14+ shell : bash
15+ run : |
16+ git fetch --tags origin
17+
18+ - name : Set up Python
19+ uses : actions/setup-python@v4
20+ with :
21+ python-version : ${{ inputs.python-version }}
22+ allow-prereleases : true
23+
24+ - name : Pip cache
25+ uses : actions/cache@v4
26+ with :
27+ path : ~/.cache/pip
28+ key : ${{ runner.os }}-pip
29+ restore-keys : |
30+ ${{ runner.os }}-pip
31+
32+ - name : " Install tools : nox"
33+ shell : bash
34+ run : |
35+ pip install --upgrade nox
36+
37+ - name : " Build Environment"
38+ shell : bash
39+ run : |
40+ printenv | sort
Original file line number Diff line number Diff line change 1+ name : Tests
2+
3+ on :
4+ pull_request :
5+ push :
6+ workflow_dispatch :
7+ workflow_call :
8+
9+ jobs :
10+ black_formatting :
11+ name : Black Format Linting
12+ runs-on : ubuntu-latest
13+ steps :
14+ - name : Checkout code
15+ uses : actions/checkout@v4
16+ - name : Prepare common Python build environment
17+ uses : ./.github/actions/python-build-env-setup
18+ - name : ' Nox: Python Black'
19+ run : |
20+ nox -s black_lint
21+
22+ pytest_all :
23+ name : PyTest with Python ${{ matrix.python-version }}
24+ runs-on : ubuntu-latest
25+ strategy :
26+ matrix :
27+ python-version : ['3.10', '3.11', '3.12', '3.13']
28+ steps :
29+ - name : Checkout code
30+ uses : actions/checkout@v4
31+ - name : Prepare common Python build environment
32+ uses : ./.github/actions/python-build-env-setup
33+ with :
34+ python-version : ${{ matrix.python-version }}
35+ - name : " Nox: Pytest ${{ matrix.python-version }}"
36+ run : |
37+ nox -s pytest-${{ matrix.python-version }}
Original file line number Diff line number Diff line change 1+ import pytest
2+ from fastmcp import FastMCP , Client
3+
4+
5+ @pytest .fixture
6+ def test_server ():
7+ mcp = FastMCP ("Planet MCP Test Server" )
8+
9+ ## a very simple "search" test
10+ @mcp .tool
11+ def search (item_type : str ) -> dict :
12+ items = {"PSScene" : 123 , "SkySat" : 456 , "Tanager" : 789 }
13+ return {"item_type" : item_type , "temp" : items .get (item_type )}
14+
15+ return mcp
16+
17+
18+ @pytest .mark .asyncio
19+ async def test_search_tool (test_server ):
20+ async with Client (test_server ) as client :
21+ result = await client .call_tool ("search" , {"item_type" : "SkySat" })
22+ assert result .data == {"item_type" : "SkySat" , "temp" : 456 }
You can’t perform that action at this time.
0 commit comments