From 27d9a94ee3cafb36992f59451ad42e803c71dc8e Mon Sep 17 00:00:00 2001 From: Piero Savastano Date: Wed, 18 Oct 2023 22:47:59 +0200 Subject: [PATCH 1/3] Update Dockerfile --- core/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Dockerfile b/core/Dockerfile index ed053045d..6d89eb316 100644 --- a/core/Dockerfile +++ b/core/Dockerfile @@ -14,7 +14,7 @@ RUN apt-get -y update && apt-get install -y curl build-essential fastjar libmagi ### ADMIN (static build) ### WORKDIR /admin -RUN curl -sL https://github.com/cheshire-cat-ai/admin-vue/releases/download/Admin/develop.zip | jar -xv +RUN curl -sL https://github.com/cheshire-cat-ai/admin-vue/releases/download/Admin/release.zip | jar -xv ### INSTALL PYTHON DEPENDENCIES (Core and Plugins) ### WORKDIR /app From 98c88c0a4b6372859f2fa1dca87373bf900a8966 Mon Sep 17 00:00:00 2001 From: mmassime Date: Wed, 15 Nov 2023 00:44:09 +0100 Subject: [PATCH 2/3] mock plugin download --- .../routes/plugins/test_plugins_registry.py | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/core/tests/routes/plugins/test_plugins_registry.py b/core/tests/routes/plugins/test_plugins_registry.py index d8c95a4da..ab95a3f3a 100644 --- a/core/tests/routes/plugins/test_plugins_registry.py +++ b/core/tests/routes/plugins/test_plugins_registry.py @@ -1,6 +1,6 @@ import os import shutil -from tests.utils import get_embedded_tools +from tests.utils import get_embedded_tools, create_mock_plugin_zip # TODO: registry responses here should be mocked, at the moment we are actually calling the service @@ -40,37 +40,41 @@ def test_list_registry_plugins_by_query(client): assert params["query"] in plugin_text # verify searched text -def test_plugin_install_from_registry(client): +def test_plugin_install_from_registry(client, monkeypatch): - new_plugin_id = "ccat_summarization" + # Mock the download from the registry creating a zip on-the-fly + monkeypatch.setattr("cat.routes.plugins.registry_download_plugin", create_mock_plugin_zip) + # during tests, the cat uses a different folder for plugins - new_plugin_final_folder = f"tests/mocks/mock_plugin_folder/{new_plugin_id}" + new_plugin_final_folder = f"tests/mocks/mock_plugin_folder/mock_plugin" + if os.path.exists(new_plugin_final_folder): shutil.rmtree(new_plugin_final_folder) assert not os.path.exists(new_plugin_final_folder) # install plugin from registry payload = { - "url": "https://github.com/Furrmidable-Crew/ccat_summarization" + "url": "https://mockup_url.com" } response = client.post("/plugins/upload/registry", json=payload) + assert response.status_code == 200 assert response.json()["url"] == payload["url"] assert response.json()["info"] == "Plugin is being installed asynchronously" # GET plugin endpoint responds - response = client.get(f"/plugins/{new_plugin_id}") + response = client.get(f"/plugins/mock_plugin") assert response.status_code == 200 json = response.json() - assert json["data"]["id"] == new_plugin_id + assert json["data"]["id"] == "mock_plugin" assert json["data"]["active"] == True - + # GET plugins endpoint lists the plugin response = client.get("/plugins") assert response.status_code == 200 installed_plugins = response.json()["installed"] installed_plugins_names = list(map(lambda p: p["id"], installed_plugins)) - assert new_plugin_id in installed_plugins_names + assert "mock_plugin" in installed_plugins_names # both core_plugin and new_plugin are active for p in installed_plugins: assert p["active"] == True @@ -79,7 +83,7 @@ def test_plugin_install_from_registry(client): assert os.path.exists(new_plugin_final_folder) # TODO: check for tools and hooks creation - + # cleanup shutil.rmtree(new_plugin_final_folder) From a0f3f3da960ef6041c036c5f63f3bdde1d3b51fc Mon Sep 17 00:00:00 2001 From: mmassime Date: Wed, 15 Nov 2023 00:46:43 +0100 Subject: [PATCH 3/3] dockerfile --- core/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Dockerfile b/core/Dockerfile index 6d89eb316..ed053045d 100644 --- a/core/Dockerfile +++ b/core/Dockerfile @@ -14,7 +14,7 @@ RUN apt-get -y update && apt-get install -y curl build-essential fastjar libmagi ### ADMIN (static build) ### WORKDIR /admin -RUN curl -sL https://github.com/cheshire-cat-ai/admin-vue/releases/download/Admin/release.zip | jar -xv +RUN curl -sL https://github.com/cheshire-cat-ai/admin-vue/releases/download/Admin/develop.zip | jar -xv ### INSTALL PYTHON DEPENDENCIES (Core and Plugins) ### WORKDIR /app