Skip to content

Commit 66233aa

Browse files
committed
Disable app
1 parent 44495b3 commit 66233aa

3 files changed

Lines changed: 38 additions & 0 deletions

File tree

holochain_client/api/admin/client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
AppInfo,
88
AppInterfaceAttached,
99
AttachAppInterface,
10+
DisableApp,
1011
DumpNetworkStats,
1112
EnableApp,
1213
GenerateAgentPubKey,
@@ -118,6 +119,10 @@ async def enable_app(self, request: EnableApp) -> AppEnabled:
118119
assert response["type"] == "app_enabled", f"response was: {response}"
119120
return AppEnabled(*response["data"])
120121

122+
async def disable_app(self, request: DisableApp):
123+
response = await self._exchange(request, tag_from_type(request))
124+
assert response["type"] == "app_disabled", f"response was: {response}"
125+
121126
async def attach_app_interface(
122127
self, request: AttachAppInterface = AttachAppInterface()
123128
) -> AppInterfaceAttached:

holochain_client/api/admin/types.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,3 +275,8 @@ class ListDnas:
275275
@dataclass
276276
class ListCellIds:
277277
pass
278+
279+
280+
@dataclass
281+
class DisableApp:
282+
installed_app_id: str

tests/api/admin/client_test.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pytest
22
from holochain_client.api.admin.types import (
33
AddAdminInterface,
4+
DisableApp,
45
DnaModifiers,
56
EnableApp,
67
InterfaceDriverWebsocket,
@@ -158,6 +159,33 @@ async def test_list_apps():
158159
assert apps[0].installed_app_id == "test_app"
159160

160161

162+
@pytest.mark.asyncio
163+
async def test_enable_and_disable_app():
164+
async with TestHarness() as harness:
165+
agent_pub_key = await harness.admin_client.generate_agent_pub_key()
166+
167+
await harness.admin_client.install_app(
168+
InstallApp(
169+
agent_key=agent_pub_key,
170+
installed_app_id="test_app",
171+
path=harness.fixture_path,
172+
)
173+
)
174+
175+
app_info = (await harness.admin_client.list_apps())[0]
176+
assert "disabled" in app_info.status
177+
178+
await harness.admin_client.enable_app(EnableApp("test_app"))
179+
180+
app_info = (await harness.admin_client.list_apps())[0]
181+
assert "running" in app_info.status
182+
183+
await harness.admin_client.disable_app(DisableApp("test_app"))
184+
185+
app_info = (await harness.admin_client.list_apps())[0]
186+
assert "disabled" in app_info.status
187+
188+
161189
@pytest.mark.asyncio
162190
async def test_attach_app_interface():
163191
async with TestHarness() as harness:

0 commit comments

Comments
 (0)