MCPcopy
hub / github.com/TaskingAI/TaskingAI / test_plugins

Function test_plugins

plugin/test/test_plugins.py:11–58  ·  view source on GitHub ↗
(test_data)

Source from the content-addressed store, hash-verified

9@pytest.mark.parametrize("test_data", generate_test_cases(), ids=lambda d: d["id"])
10@pytest.mark.asyncio
11async def test_plugins(test_data):
12 bundle_id = test_data["id"].split("/")[0]
13 plugin_id = test_data["id"].split("/")[1]
14 if bundle_id == "stability_ai":
15 pytest.skip("Skipping test as bundle_id is not provided")
16 output_schema = test_data["output_schema"]
17 bundle_credentials = test_data["bundle_credentials"]
18 mode = test_data["mode"]
19 input_params = test_data["input"]
20 output = test_data["output"]
21
22 bundle_credentials = {credential: os.environ.get(credential) for credential in bundle_credentials}
23
24 async with aiohttp.ClientSession() as session:
25 request_data = {
26 "bundle_id": bundle_id,
27 "plugin_id": plugin_id,
28 "input_params": input_params,
29 "credentials": bundle_credentials,
30 "project_id": "test_project_id",
31 }
32
33 error_data_to_print = {
34 "bundle_id": bundle_id,
35 "plugin_id": plugin_id,
36 "input_params": input_params,
37 "credentials": {
38 credential: bundle_credentials.get(credential, "NOT FOUND")[:4] for credential in bundle_credentials
39 },
40 }
41 async with session.post("http://localhost:8000/v1/execute", json=request_data) as response:
42 result = await response.json()
43 if mode == "schema":
44 assert result["status"] == "success", f"test failed, request = {error_data_to_print}, result = {result}"
45 assert (
46 result["data"]["status"] == 200
47 ), f"test failed, request = {error_data_to_print}, result = {result}"
48 for key in output_schema:
49 assert (
50 key in result["data"]["data"]
51 ), f"test failed, request = {error_data_to_print}, result = {result}"
52
53 if mode == "precise":
54 assert result["status"] == "success", f"test failed, request = {error_data_to_print}, result = {result}"
55 for key in output:
56 assert (
57 result["data"]["data"][key] == output[key]
58 ), f"test failed, request = {error_data_to_print}, result = {result}"

Callers

nothing calls this directly

Calls 2

getMethod · 0.45
jsonMethod · 0.45

Tested by

no test coverage detected