Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
before(async function() {
// tslint:disable-next-line:no-invalid-this
this.timeout(60000);
const path = UUID.uuid4();
[local, foreign, session] = await Promise.all([
Session.startNew({ path }),
Session.startNew({ path }),
createClientSession({ path })
]);
// check path prop
expect(local.path).to.equal(path);
await (session as ClientSession).initialize();
await session.kernel.ready;
});
function main() {
// Start a new session.
let options: Session.IOptions = {
kernelName: 'python',
path: 'foo.ipynb'
};
let session: Session.ISession;
log('Starting session');
Session.startNew(options)
.then(s => {
log('Session started');
session = s;
// Rename the session.
return session.setPath('bar.ipynb');
})
.then(() => {
log(`Session renamed to ${session.path}`);
// Execute and handle replies on the kernel.
let future = session.kernel.requestExecute({ code: 'a = 1' });
future.onReply = reply => {
log('Got execute reply');
};
return future.done;
})
.then(() => {
it('should fail for wrong response status', async () => {
const sessionModel = createSessionModel();
const serverSettings = getRequestHandler(200, sessionModel);
const options = createSessionOptions(sessionModel, serverSettings);
const sessionPromise = Session.startNew(options);
await expectFailure(sessionPromise);
});
beforeEach(done => {
Session.startNew({ path: utils.uuid() }).then(newSession => {
session = newSession;
widget = new TestContent({ renderer, rendermime, session });
done();
});
});
async startSession(): Promise {
handleRequest(this, 201, createSessionModel());
const serverSettings = this.serverSettings;
this._session = await Session.startNew({
path: UUID.uuid4(),
serverSettings
});
await this.ready;
await this._session.kernel.ready;
return this._session;
}
function startNew(): Promise {
return Session.startNew({ path: UUID.uuid4() });
}
function startNew(): Promise {
return Session.startNew({ path: UUID.uuid4() });
}
beforeAll(async () => {
session = await Session.startNew({ path: UUID.uuid4() });
await session.kernel.ready;
});
}, () => {
let options: Session.IOptions = {
type: 'python2',
path: Kernels.session_path
};
return Session.startNew(options).then(s => {
this.session = s;
return this.session;
}, r => {
throw new Error("Unable to start session")
});
})
} else {
startSession(gatewayName: string, sessionInfo: any) {
Session.startNew(sessionInfo.options).then(
this.onSessionChosen.bind(this, gatewayName)
);
}