Skip to content

Commit

Permalink
rename mock_plugin tool; fix ambiguous assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
pieroit committed Aug 4, 2023
1 parent 2646774 commit 36f9d17
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions core/tests/mocks/mock_plugin/mock_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


@tool(return_direct=True)
def random_idea(topic, cat):
"""Use to produce random ideas. Input is the topic."""
def mock_tool(topic, cat):
"""Used to test mock tools. Input is the topic."""

return f"A random idea about {topic} :)"
return f"A mock about {topic} :)"
16 changes: 8 additions & 8 deletions core/tests/routes/plugins/test_plugin_toggle.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ def test_deactivate_plugin(client, just_installed_plugin):
installed_plugins = response.json()["installed"]
mock_plugin = [p for p in installed_plugins if p["id"] == "mock_plugin"]
assert len(mock_plugin) == 1 # plugin installed
assert not mock_plugin[0]["active"] # plugin NOT active
assert mock_plugin[0]["active"] == False # plugin NOT active

# GET plugin info, plugin is not active
# GET single plugin info, plugin is not active
response = client.get("/plugins/mock_plugin")
assert not response.json()["data"]["active"]
assert response.json()["data"]["active"] == False

# tool has been taken away
tools = get_embedded_tools(client)
tool_names = list(map(lambda t: t["metadata"]["name"], tools))
assert not "random_idea" in tool_names
assert not "mock_tool" in tool_names


def test_reactivate_plugin(client, just_installed_plugin):
Expand All @@ -47,13 +47,13 @@ def test_reactivate_plugin(client, just_installed_plugin):
installed_plugins = response.json()["installed"]
mock_plugin = [p for p in installed_plugins if p["id"] == "mock_plugin"]
assert len(mock_plugin) == 1 # plugin installed
assert mock_plugin[0]["active"] # plugin active
assert mock_plugin[0]["active"] == True # plugin active

# GET plugin info, plugin is active
# GET single plugin info, plugin is active
response = client.get("/plugins/mock_plugin")
assert response.json()["data"]["active"]
assert response.json()["data"]["active"] == True

# tool has been re-embedded
tools = get_embedded_tools(client)
tool_names = list(map(lambda t: t["metadata"]["name"], tools))
assert "random_idea" in tool_names
assert "mock_tool" in tool_names
4 changes: 2 additions & 2 deletions core/tests/routes/plugins/test_plugins_install_uninstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_plugin_install_upload_zip(client, just_installed_plugin):
# check whether new tools have been embedded
tools = get_embedded_tools(client)
tool_names = list(map(lambda t: t["metadata"]["name"], tools))
assert "random_idea" in tool_names
assert "mock_tool" in tool_names


def test_plugin_uninstall(client, just_installed_plugin):
Expand All @@ -50,4 +50,4 @@ def test_plugin_uninstall(client, just_installed_plugin):
# plugin tool disappeared
tools = get_embedded_tools(client)
tool_names = list(map(lambda t: t["metadata"]["name"], tools))
assert "random_idea" not in tool_names
assert "mock_tool" not in tool_names

0 comments on commit 36f9d17

Please sign in to comment.