Ejemplo n.º 1
6
    execute: args => {
      // Clone the OutputArea
      const current = getCurrent({ ...args, activate: false });
      const nb = current.notebook;
      const outputAreaView = (nb.activeCell as CodeCell).cloneOutputArea();
      // Create an empty toolbar
      const toolbar = new Widget();
      toolbar.addClass('jp-Toolbar');
      toolbar.addClass('jp-LinkedOutputView-toolbar');
      // Create a MainAreaWidget
      const layout = new PanelLayout();
      const widget = new MainAreaWidget({ layout });
      widget.id = `LinkedOutputView-${uuid()}`;
      widget.title.label = 'Output View';
      widget.title.icon = NOTEBOOK_ICON_CLASS;
      widget.title.caption = current.title.label ? `For Notebook: ${current.title.label}` : 'For Notebook:';
      widget.addClass('jp-LinkedOutputView');
      layout.addWidget(toolbar);
      layout.addWidget(outputAreaView);
      current.context.addSibling(
        widget, { ref: current.id, mode: 'split-bottom' }
      );

      // Remove the output view if the parent notebook is closed.
      nb.disposed.connect(widget.dispose);
    },
Ejemplo n.º 2
0
 it('should accept a length', () => {
   let id0 = uuid(10);
   let id1 = uuid(10);
   expect(id0.length).to.equal(10);
   expect(id1.length).to.equal(10);
   expect(id0).to.not.equal(id1);
 });
Ejemplo n.º 3
0
/**
 * Create a unique session id.
 */
function createSessionModel(id = ''): Session.IModel {
  return {
    id: id || uuid(),
    notebook: { path: uuid() },
    kernel: { id: uuid(), name: uuid() }
  };
}
Ejemplo n.º 4
0
    it('should not be emitted for an iopub signal', async () => {
      const kernel = await tester.start();

      // We'll send two messages, first an iopub message, then a shell message.
      // The unhandledMessage signal should only emit once for the shell message.
      const msgId = uuid();
      const emission = testEmission(kernel.unhandledMessage, {
        test: (k, msg) => { expect(msg.header.msg_id).to.be(msgId); }
      });

      // Send an iopub message.
      tester.sendStatus(uuid(), 'idle');

      // Send a shell message.
      let msg = KernelMessage.createShellMessage({
        msgType: 'foo',
        channel: 'shell',
        session: tester.serverSessionId,
        msgId
      });
      msg.parent_header = {session: kernel.clientId};
      tester.send(msg);

      await emission;
    });
Ejemplo n.º 5
0
 it('should generate a random 32 character hex string', () => {
   let id0 = uuid();
   let id1 = uuid();
   expect(id0.length).to.equal(32);
   expect(id1.length).to.equal(32);
   expect(id0).to.not.equal(id1);
 });
Ejemplo n.º 6
0
/**
 * Create a unique session id.
 */
function createSessionModel(id = ''): Session.IModel {
  return {
    id: id || uuid(),
    path: uuid(),
    type: '',
    name: '',
    kernel: { id: uuid(), name: uuid() }
  };
}
Ejemplo n.º 7
0
 beforeEach((done) => {
   tester = new KernelTester();
   data = [{ id: uuid(), name: 'test' },
           { id: uuid(), name: 'test2' }];
   tester.runningKernels = data;
   manager = new KernelManager();
   expect(manager.specs).to.be(null);
   expect(manager.running().next()).to.be(void 0);
   manager.ready.then(done, done);
 });
Ejemplo n.º 8
0
 it('should accept server settings', (done) => {
   let data = [
     { id: uuid(), name: 'test' },
     { id: uuid(), name: 'test2' }
   ];
   tester.runningKernels = data;
   Kernel.listRunning(serverSettings).then(response => {
     let running = toArray(response);
     expect(running[0]).to.eql(data[0]);
     expect(running[1]).to.eql(data[1]);
     done();
   });
 });
Ejemplo n.º 9
0
 it('should yield a list of valid kernel ids', (done) => {
   let data = [
     { id: uuid(), name: 'test' },
     { id: uuid(), name: 'test2' }
   ];
   tester.runningKernels = data;
   Kernel.listRunning().then(response => {
     let running = toArray(response);
     expect(running[0]).to.eql(data[0]);
     expect(running[1]).to.eql(data[1]);
     done();
   });
 });
Ejemplo n.º 10
0
 manager.startNew({ path: 'foo' }).then(s => {
   let model = {
     id: s.id,
     kernel: {
       name: 'foo',
       id: uuid()
     },
     path: 'bar',
     name: '',
     type: ''
   };
   let name = model.kernel.name;
   tester.onRequest = request => {
     if (request.method === 'PATCH') {
       tester.respond(200, model);
     } else {
       tester.respond(200, { name, id: model.kernel.id });
     }
   };
   manager.runningChanged.connect(() => {
     manager.dispose();
     done();
   });
   return s.changeKernel({ name });
 }).catch(done);