Skip to content

Commit

Permalink
Fix handling of extension last activity (#1145)
Browse files Browse the repository at this point in the history
Fixes #1135
  • Loading branch information
blink1073 authored Dec 21, 2022
1 parent 1d61ff2 commit 53377e2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion jupyter_server/serverapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ def last_activity(self):
# counted here. This provides a hook for extensions to add a last activity
# setting to the server.
sources.extend(
[key for key, val in self.settings.items() if key.endswith("_last_activity")]
[val for key, val in self.settings.items() if key.endswith("_last_activity")]
)
sources.extend(self.settings["last_activity_times"].values())
return max(sources)
Expand Down
12 changes: 10 additions & 2 deletions tests/test_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from tornado.httpclient import HTTPClientError
from traitlets.config import Config

from jupyter_server._tz import isoformat


@pytest.fixture
def terminal_path(tmp_path):
Expand Down Expand Up @@ -67,7 +69,7 @@ async def test_no_terminals(jp_fetch):
assert len(data) == 0


async def test_terminal_create(jp_fetch):
async def test_terminal_create(jp_fetch, jp_serverapp):
resp = await jp_fetch(
"api",
"terminals",
Expand Down Expand Up @@ -115,7 +117,7 @@ async def test_terminal_create_with_kwargs(jp_fetch, jp_ws_fetch, terminal_path)
assert data["name"] == term_name


async def test_terminal_create_with_cwd(jp_fetch, jp_ws_fetch, terminal_path):
async def test_terminal_create_with_cwd(jp_fetch, jp_ws_fetch, terminal_path, jp_serverapp):
resp = await jp_fetch(
"api",
"terminals",
Expand Down Expand Up @@ -147,6 +149,12 @@ async def test_terminal_create_with_cwd(jp_fetch, jp_ws_fetch, terminal_path):

assert os.path.basename(terminal_path) in message_stdout

resp = await jp_fetch("api", "status")
data = json.loads(resp.body.decode())
assert data["last_activity"] == isoformat(
jp_serverapp.web_app.settings["terminal_last_activity"]
)


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

0 comments on commit 53377e2

Please sign in to comment.