當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript services.SessionManager類代碼示例

本文整理匯總了TypeScript中@jupyterlab/services.SessionManager的典型用法代碼示例。如果您正苦於以下問題:TypeScript SessionManager類的具體用法?TypeScript SessionManager怎麽用?TypeScript SessionManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了SessionManager類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: describe

  describe('ClientSession', () => {
    const manager = new SessionManager();
    let session: ClientSession;

    before(() => manager.ready);

    beforeEach(() => {
      session = new ClientSession({
        manager,
        kernelPreference: { name: manager.specs.default }
      });
    });

    afterEach(async () => {
      await session.shutdown();
      session.dispose();
    });

    describe('#constructor()', () => {
      it('should create a client session', () => {
        expect(session).to.be.an.instanceof(ClientSession);
      });
    });

    describe('#terminated', () => {
      it('should be emitted when the session is terminated', async () => {
        await session.initialize();
        session.terminated.connect((sender, args) => {
          expect(sender).to.equal(session);
          expect(args).to.be.undefined;
        });
        await session.shutdown();
      });
    });

    describe('#kernelChanged', () => {
      it('should be emitted when the kernel changes', async () => {
        session.kernelChanged.connect((sender, { oldValue, newValue }) => {
          expect(sender).to.equal(session);
          expect(oldValue).to.be.null;
          expect(newValue).to.equal(session.kernel);
        });
        await session.initialize();
      });
    });

    describe('#statusChanged', () => {
      it('should be emitted when the status changes', async () => {
        session.statusChanged.connect((sender, args) => {
          expect(sender).to.equal(session);
          expect(typeof args).to.equal('string');
        });
        await session.initialize();
      });
    });

    describe('#iopubMessage', () => {
      it('should be emitted for iopub kernel messages', async () => {
        session.iopubMessage.connect((sender, args) => {
          expect(sender).to.equal(session);
        });
        await session.initialize();
      });
    });

    describe('#propertyChanged', () => {
      it('should be emitted when a session path changes', async () => {
        session.kernelPreference = { canStart: false };
        session.propertyChanged.connect((sender, args) => {
          expect(sender).to.equal(session);
          expect(args).to.equal('path');
        });
        await session.setPath('foo');
      });

      it('should be emitted when a session name changes', async () => {
        session.kernelPreference = { canStart: false };
        session.propertyChanged.connect((sender, args) => {
          expect(sender).to.equal(session);
          expect(args).to.equal('name');
        });
        await session.setName('foo');
      });

      it('should be emitted when a session type changes', async () => {
        session.kernelPreference = { canStart: false };
        session.propertyChanged.connect((sender, args) => {
          expect(sender).to.equal(session);
          expect(args).to.equal('type');
        });
        await session.setType('foo');
      });
    });

    describe('#kernel', () => {
      it('should be the current kernel of the the session', async () => {
        expect(session.kernel).to.be.null;
        await session.initialize();
        expect(session.kernel).to.be.ok;
      });
//.........這裏部分代碼省略.........
開發者ID:willingc,項目名稱:jupyterlab,代碼行數:101,代碼來源:clientsession.spec.ts

示例2: describe

  describe('ClientSession', () => {

    const manager = new SessionManager();
    let session: ClientSession;

    before(() => {
      return manager.ready;
    });

    beforeEach(() => {
      session = new ClientSession({
        manager, kernelPreference: { name: manager.specs.default }
      });
    });

    afterEach(() => {
      return session.shutdown().then(() => {
        session.dispose();
      });
    });

    describe('#constructor()', () => {

      it('should create a client session', () => {
        expect(session).to.be.a(ClientSession);
      });

    });

    describe('#terminated', () => {

      it('should be emitted when the session is terminated', (done) => {
        session.initialize().then(() => {
          session.terminated.connect((sender, args) => {
            expect(sender).to.be(session);
            expect(args).to.be(undefined);
            done();
          });
          return session.shutdown();
        }).catch(done);
      });

    });

    describe('#kernelChanged', () => {

      it('should be emitted when the kernel changes', (done) => {
        session.kernelChanged.connect((sender, args) => {
          expect(sender).to.be(session);
          expect(args).to.be.ok();
          done();
        });
        session.initialize().catch(done);
      });

    });

    describe('#statusChanged', () => {

      it('should be emitted when the status changes', (done) => {
        session.statusChanged.connect((sender, args) => {
          expect(sender).to.be(session);
          expect(typeof args).to.be('string');
          done();
        });
        session.initialize().catch(done);
      });

    });

    describe('#iopubMessage', () => {

      it('should be emitted for iopub kernel messages', (done) => {
        session.iopubMessage.connect((sender, args) => {
          expect(sender).to.be(session);
          done();
        });
        session.initialize().catch(done);
      });

    });

    describe('#propertyChanged', () => {

      it('should be emitted when a session path changes', (done) => {
        session.kernelPreference = { canStart: false };
        session.propertyChanged.connect((sender, args) => {
          expect(sender).to.be(session);
          expect(args).to.be('path');
          done();
        });
        session.setPath('foo').catch(done);
      });

      it('should be emitted when a session name changes', (done) => {
        session.kernelPreference = { canStart: false };
        session.propertyChanged.connect((sender, args) => {
          expect(sender).to.be(session);
          expect(args).to.be('name');
          done();
//.........這裏部分代碼省略.........
開發者ID:SimonBiggs,項目名稱:jupyterlab,代碼行數:101,代碼來源:clientsession.spec.ts

示例3: it

      it('should connect to an existing session on the path', async () => {
        const other = await manager.startNew({ path: session.path });

        await session.initialize();
        expect(other.kernel.id).to.equal(session.kernel.id);
        other.dispose();
      });
開發者ID:willingc,項目名稱:jupyterlab,代碼行數:7,代碼來源:clientsession.spec.ts

示例4: it

 it('should connect to an existing session on the path', () => {
   let other: Session.ISession;
   return manager.startNew({ path: session.path }).then(o => {
     other = o;
     return session.initialize();
   }).then(() => {
     expect(session.kernel.id).to.be(other.kernel.id);
     return other.dispose();
   });
 });
開發者ID:SimonBiggs,項目名稱:jupyterlab,代碼行數:10,代碼來源:clientsession.spec.ts

示例5: it

      it('should connect to an existing kernel', async () => {
        // Shut down and dispose the session so it can be re-instantiated.
        await session.shutdown();
        session.dispose();

        const other = await manager.startNew({ path: UUID.uuid4() });
        const kernelPreference = { id: other.kernel.id };

        session = new ClientSession({ manager, kernelPreference });
        await session.initialize();
        expect(session.kernel.id).to.equal(other.kernel.id);
        // We don't call other.shutdown() here because that
        // is handled by the afterEach() handler above.
        other.dispose();
      });
開發者ID:afshin,項目名稱:jupyterlab,代碼行數:15,代碼來源:clientsession.spec.ts


注:本文中的@jupyterlab/services.SessionManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。