File tree Expand file tree Collapse file tree 2 files changed +19
-9
lines changed
jupyter_server/services/api Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Original file line number Diff line number Diff line change 9
9
from tornado import web
10
10
11
11
from ...base .handlers import JupyterHandler , APIHandler
12
+ from jupyter_server .utils import ensure_async
12
13
from jupyter_server ._tz import utcfromtimestamp , isoformat
13
14
14
15
@@ -36,7 +37,7 @@ async def get(self):
36
37
started = self .settings .get ('started' , utcfromtimestamp (0 ))
37
38
started = isoformat (started )
38
39
39
- kernels = await self .kernel_manager .list_kernels ()
40
+ kernels = await ensure_async ( self .kernel_manager .list_kernels () )
40
41
total_connections = sum (k ['connections' ] for k in kernels )
41
42
last_activity = isoformat (self .application .last_activity ())
42
43
model = {
Original file line number Diff line number Diff line change 1
- import pytest
2
-
3
- from jupyter_server .utils import url_path_join
1
+ import json
4
2
5
3
6
4
async def test_get_spec (fetch ):
7
- response = await fetch (
8
- 'api' , 'spec.yaml' ,
9
- method = 'GET'
10
- )
5
+ response = await fetch ("api" , "spec.yaml" , method = "GET" )
11
6
assert response .code == 200
12
7
13
8
14
-
9
+ async def test_get_status (fetch ):
10
+ response = await fetch ("api" , "status" , method = "GET" )
11
+ assert response .code == 200
12
+ assert response .headers .get ("Content-Type" ) == "application/json"
13
+ status = json .loads (response .body .decode ("utf8" ))
14
+ assert sorted (status .keys ()) == [
15
+ "connections" ,
16
+ "kernels" ,
17
+ "last_activity" ,
18
+ "started" ,
19
+ ]
20
+ assert status ["connections" ] == 0
21
+ assert status ["kernels" ] == 0
22
+ assert status ["last_activity" ].endswith ("Z" )
23
+ assert status ["started" ].endswith ("Z" )
You can’t perform that action at this time.
0 commit comments