mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Add test cases to ensure proper serialization
This commit is contained in:
@@ -19,7 +19,9 @@ openai = pytest.importorskip("openai")
|
||||
TEST_VISUALIZATION_PLUGINS_DIR = os.path.join(os.path.dirname(__file__), "test_visualization_plugins")
|
||||
|
||||
|
||||
class TestAiApi(IntegrationTestCase):
|
||||
class TestVisualizationPluginsApi(IntegrationTestCase):
|
||||
"""Tests for the visualization plugins API endpoints."""
|
||||
|
||||
@classmethod
|
||||
def handle_galaxy_config_kwds(cls, config) -> None:
|
||||
config["ai_api_key"] = "ai_api_key"
|
||||
@@ -27,6 +29,62 @@ class TestAiApi(IntegrationTestCase):
|
||||
config["ai_model"] = "ai_model"
|
||||
config["visualization_plugins_directory"] = TEST_VISUALIZATION_PLUGINS_DIR
|
||||
|
||||
def test_index(self):
|
||||
"""Test that GET /api/plugins returns a list of plugins."""
|
||||
response = self._get("plugins")
|
||||
self._assert_status_code_is(response, 200)
|
||||
plugins = response.json()
|
||||
assert isinstance(plugins, list)
|
||||
|
||||
def test_show_returns_all_fields(self):
|
||||
"""Test that GET /api/plugins/{id} returns all expected fields including params, tags, tests, help, data_sources."""
|
||||
response = self._get("plugins/jupyterlite")
|
||||
self._assert_status_code_is(response, 200)
|
||||
plugin = response.json()
|
||||
|
||||
# Verify required fields
|
||||
assert plugin["name"] == "jupyterlite"
|
||||
assert plugin["html"] == "JupyterLite Test"
|
||||
assert plugin["description"] == "Test fixture for visualization plugin integration tests"
|
||||
assert plugin["embeddable"] is False
|
||||
assert "entry_point" in plugin
|
||||
assert "href" in plugin
|
||||
|
||||
# Verify params are returned correctly
|
||||
assert "params" in plugin
|
||||
params = plugin["params"]
|
||||
assert "dataset_id" in params
|
||||
assert params["dataset_id"]["required"] is True
|
||||
assert params["dataset_id"]["type"] == "str"
|
||||
assert "limit" in params
|
||||
assert params["limit"]["required"] is False
|
||||
assert params["limit"]["type"] == "int"
|
||||
assert params["limit"]["default"] == "10"
|
||||
|
||||
# Verify data_sources are returned
|
||||
assert "data_sources" in plugin
|
||||
data_sources = plugin["data_sources"]
|
||||
assert len(data_sources) >= 1
|
||||
assert data_sources[0]["model_class"] == "HistoryDatasetAssociation"
|
||||
|
||||
# Verify specs are returned
|
||||
assert "specs" in plugin
|
||||
assert plugin["specs"]["custom_setting"] == "test_value"
|
||||
|
||||
# Verify tags are returned
|
||||
assert "tags" in plugin
|
||||
tags = plugin["tags"]
|
||||
assert "Test" in tags
|
||||
assert "Integration" in tags
|
||||
|
||||
# Verify help is returned
|
||||
assert "help" in plugin
|
||||
assert "test help text" in plugin["help"]
|
||||
|
||||
# Verify tests are returned
|
||||
assert "tests" in plugin
|
||||
assert len(plugin["tests"]) >= 1
|
||||
|
||||
def _create_payload(self, extra=None):
|
||||
payload = {
|
||||
"messages": [{"role": "user", "content": "hi"}],
|
||||
|
||||
@@ -1,13 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<visualization name="JupyterLite Test" hidden="true">
|
||||
<description>Test fixture for AI chat integration tests</description>
|
||||
<description>Test fixture for visualization plugin integration tests</description>
|
||||
<data_sources>
|
||||
<data_source>
|
||||
<model_class>HistoryDatasetAssociation</model_class>
|
||||
</data_source>
|
||||
</data_sources>
|
||||
<params>
|
||||
<param required="true">dataset_id</param>
|
||||
<param type="int" required="false" default="10">limit</param>
|
||||
</params>
|
||||
<entry_point entry_point_type="script" src="script.js" />
|
||||
<specs>
|
||||
<ai_prompt>test prompt</ai_prompt>
|
||||
<custom_setting>test_value</custom_setting>
|
||||
</specs>
|
||||
<tags>
|
||||
<tag>Test</tag>
|
||||
<tag>Integration</tag>
|
||||
</tags>
|
||||
<help>This is test help text for the JupyterLite test plugin.</help>
|
||||
<tests>
|
||||
<test>
|
||||
<param name="dataset_id" value="test.tabular" />
|
||||
</test>
|
||||
</tests>
|
||||
</visualization>
|
||||
|
||||
Reference in New Issue
Block a user