|
79 | 79 | ImportErrorResponse, |
80 | 80 | JobCollectionResponse, |
81 | 81 | JobResponse, |
| 82 | + PluginCollectionResponse, |
| 83 | + PluginImportErrorCollectionResponse, |
| 84 | + PluginImportErrorResponse, |
| 85 | + PluginResponse, |
82 | 86 | PoolBody, |
83 | 87 | PoolCollectionResponse, |
84 | 88 | PoolResponse, |
@@ -1703,3 +1707,53 @@ def handle_request(request: httpx.Request) -> httpx.Response: |
1703 | 1707 | map_index=self.map_index, |
1704 | 1708 | ) |
1705 | 1709 | assert response == self.key |
| 1710 | + |
| 1711 | + |
| 1712 | +class TestPluginsOperations: |
| 1713 | + plugin_response = PluginResponse( |
| 1714 | + name="test-plugin", |
| 1715 | + macros=[], |
| 1716 | + flask_blueprints=[], |
| 1717 | + fastapi_apps=[], |
| 1718 | + fastapi_root_middlewares=[], |
| 1719 | + external_views=[], |
| 1720 | + react_apps=[], |
| 1721 | + appbuilder_views=[], |
| 1722 | + appbuilder_menu_items=[], |
| 1723 | + global_operator_extra_links=[], |
| 1724 | + operator_extra_links=[], |
| 1725 | + source="test-source", |
| 1726 | + listeners=[], |
| 1727 | + timetables=[], |
| 1728 | + ) |
| 1729 | + plugin_collection_response = PluginCollectionResponse(plugins=[plugin_response], total_entries=1) |
| 1730 | + plugin_import_error_response = PluginImportErrorResponse( |
| 1731 | + source="plugins/test_plugin.py", error="something went wrong" |
| 1732 | + ) |
| 1733 | + plugin_import_error_collection_response = PluginImportErrorCollectionResponse( |
| 1734 | + import_errors=[plugin_import_error_response], total_entries=1 |
| 1735 | + ) |
| 1736 | + |
| 1737 | + def test_list(self): |
| 1738 | + """Test listing plugins""" |
| 1739 | + |
| 1740 | + def handle_request(request: httpx.Request) -> httpx.Response: |
| 1741 | + assert request.url.path == ("/api/v2/plugins") |
| 1742 | + return httpx.Response(200, json=json.loads(self.plugin_collection_response.model_dump_json())) |
| 1743 | + |
| 1744 | + client = make_api_client(transport=httpx.MockTransport(handle_request)) |
| 1745 | + response = client.plugins.list() |
| 1746 | + assert response == self.plugin_collection_response |
| 1747 | + |
| 1748 | + def test_list_import_errors(self): |
| 1749 | + """Test listing plugin import errors""" |
| 1750 | + |
| 1751 | + def handle_request(request: httpx.Request) -> httpx.Response: |
| 1752 | + assert request.url.path == "/api/v2/plugins/importErrors" |
| 1753 | + return httpx.Response( |
| 1754 | + 200, json=json.loads(self.plugin_import_error_collection_response.model_dump_json()) |
| 1755 | + ) |
| 1756 | + |
| 1757 | + client = make_api_client(transport=httpx.MockTransport(handle_request)) |
| 1758 | + response = client.plugins.list_import_errors() |
| 1759 | + assert response == self.plugin_import_error_collection_response |
0 commit comments