Skip to content

Commit

Permalink
Fix dummy objects for SessionManager tests
Browse files Browse the repository at this point in the history
  • Loading branch information
takluyver committed Oct 31, 2018
1 parent fd0b60c commit c76e6bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion notebook/services/kernels/kernelmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def kernel_model(self, kernel_id):
"name": kernel.kernel_type,
"last_activity": isoformat(kernel.last_activity),
"execution_state": kernel.execution_state,
"connections": self._kernels[kernel_id].n_connections,
"connections": kernel.n_connections,
}
return model

Expand Down
11 changes: 6 additions & 5 deletions notebook/services/sessions/tests/test_sessionmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
from tornado import gen, web
from tornado.ioloop import IOLoop

from jupyter_kernel_mgmt.discovery import KernelFinder
from ..sessionmanager import SessionManager
from notebook.services.kernels.kernelmanager import MappingKernelManager
from notebook.services.contents.manager import ContentsManager
from notebook._tz import utcnow, isoformat

class DummyKernel(object):
def __init__(self, kernel_name='python'):
self.kernel_name = kernel_name
def __init__(self, kernel_type='python'):
self.kernel_type = kernel_type

dummy_date = utcnow()
dummy_date_s = isoformat(dummy_date)
Expand All @@ -29,8 +30,8 @@ def _new_id(self):

def start_kernel(self, kernel_id=None, path=None, kernel_name='python', **kwargs):
kernel_id = kernel_id or self._new_id()
k = self._kernels[kernel_id] = DummyKernel(kernel_name=kernel_name)
self._kernel_connections[kernel_id] = 0
k = self._kernels[kernel_id] = DummyKernel(kernel_type=kernel_name)
k.n_connections = 0
k.last_activity = dummy_date
k.execution_state = 'idle'
return kernel_id
Expand All @@ -43,7 +44,7 @@ class TestSessionManager(TestCase):

def setUp(self):
self.sm = SessionManager(
kernel_manager=DummyMKM(),
kernel_manager=DummyMKM(kernel_finder=KernelFinder(providers=[])),
contents_manager=ContentsManager(),
)
self.loop = IOLoop()
Expand Down

0 comments on commit c76e6bf

Please sign in to comment.