|
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, |
@@ -1732,3 +1736,53 @@ def handle_request(request: httpx.Request) -> httpx.Response: |
1732 | 1736 | map_index=self.map_index, |
1733 | 1737 | ) |
1734 | 1738 | assert response == self.key |
| 1739 | + |
| 1740 | + |
| 1741 | +class TestPluginsOperations: |
| 1742 | + plugin_response = PluginResponse( |
| 1743 | + name="test-plugin", |
| 1744 | + macros=[], |
| 1745 | + flask_blueprints=[], |
| 1746 | + fastapi_apps=[], |
| 1747 | + fastapi_root_middlewares=[], |
| 1748 | + external_views=[], |
| 1749 | + react_apps=[], |
| 1750 | + appbuilder_views=[], |
| 1751 | + appbuilder_menu_items=[], |
| 1752 | + global_operator_extra_links=[], |
| 1753 | + operator_extra_links=[], |
| 1754 | + source="test-source", |
| 1755 | + listeners=[], |
| 1756 | + timetables=[], |
| 1757 | + ) |
| 1758 | + plugin_collection_response = PluginCollectionResponse(plugins=[plugin_response], total_entries=1) |
| 1759 | + plugin_import_error_response = PluginImportErrorResponse( |
| 1760 | + source="plugins/test_plugin.py", error="something went wrong" |
| 1761 | + ) |
| 1762 | + plugin_import_error_collection_response = PluginImportErrorCollectionResponse( |
| 1763 | + import_errors=[plugin_import_error_response], total_entries=1 |
| 1764 | + ) |
| 1765 | + |
| 1766 | + def test_list(self): |
| 1767 | + """Test listing plugins""" |
| 1768 | + |
| 1769 | + def handle_request(request: httpx.Request) -> httpx.Response: |
| 1770 | + assert request.url.path == ("/api/v2/plugins") |
| 1771 | + return httpx.Response(200, json=json.loads(self.plugin_collection_response.model_dump_json())) |
| 1772 | + |
| 1773 | + client = make_api_client(transport=httpx.MockTransport(handle_request)) |
| 1774 | + response = client.plugins.list() |
| 1775 | + assert response == self.plugin_collection_response |
| 1776 | + |
| 1777 | + def test_list_import_errors(self): |
| 1778 | + """Test listing plugin import errors""" |
| 1779 | + |
| 1780 | + def handle_request(request: httpx.Request) -> httpx.Response: |
| 1781 | + assert request.url.path == "/api/v2/plugins/importErrors" |
| 1782 | + return httpx.Response( |
| 1783 | + 200, json=json.loads(self.plugin_import_error_collection_response.model_dump_json()) |
| 1784 | + ) |
| 1785 | + |
| 1786 | + client = make_api_client(transport=httpx.MockTransport(handle_request)) |
| 1787 | + response = client.plugins.list_import_errors() |
| 1788 | + assert response == self.plugin_import_error_collection_response |
0 commit comments