Skip to content

Commit 53377e2

Browse files
authored
Fix handling of extension last activity (#1145)
Fixes #1135
1 parent 1d61ff2 commit 53377e2

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

jupyter_server/serverapp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ def last_activity(self):
480480
# counted here. This provides a hook for extensions to add a last activity
481481
# setting to the server.
482482
sources.extend(
483-
[key for key, val in self.settings.items() if key.endswith("_last_activity")]
483+
[val for key, val in self.settings.items() if key.endswith("_last_activity")]
484484
)
485485
sources.extend(self.settings["last_activity_times"].values())
486486
return max(sources)

tests/test_terminal.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from tornado.httpclient import HTTPClientError
1010
from traitlets.config import Config
1111

12+
from jupyter_server._tz import isoformat
13+
1214

1315
@pytest.fixture
1416
def terminal_path(tmp_path):
@@ -67,7 +69,7 @@ async def test_no_terminals(jp_fetch):
6769
assert len(data) == 0
6870

6971

70-
async def test_terminal_create(jp_fetch):
72+
async def test_terminal_create(jp_fetch, jp_serverapp):
7173
resp = await jp_fetch(
7274
"api",
7375
"terminals",
@@ -115,7 +117,7 @@ async def test_terminal_create_with_kwargs(jp_fetch, jp_ws_fetch, terminal_path)
115117
assert data["name"] == term_name
116118

117119

118-
async def test_terminal_create_with_cwd(jp_fetch, jp_ws_fetch, terminal_path):
120+
async def test_terminal_create_with_cwd(jp_fetch, jp_ws_fetch, terminal_path, jp_serverapp):
119121
resp = await jp_fetch(
120122
"api",
121123
"terminals",
@@ -147,6 +149,12 @@ async def test_terminal_create_with_cwd(jp_fetch, jp_ws_fetch, terminal_path):
147149

148150
assert os.path.basename(terminal_path) in message_stdout
149151

152+
resp = await jp_fetch("api", "status")
153+
data = json.loads(resp.body.decode())
154+
assert data["last_activity"] == isoformat(
155+
jp_serverapp.web_app.settings["terminal_last_activity"]
156+
)
157+
150158

151159
@pytest.mark.skip(reason="Not yet working")
152160
async def test_terminal_create_with_relative_cwd(

0 commit comments

Comments
 (0)