Skip to content

Fix handling of extension last activity #1145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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