Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
sock.on('message', (msg: any) => {
if (msg instanceof Buffer) {
msg = new Uint8Array(msg).buffer;
}
const data = deserialize(msg);
if (data.header.msg_type === 'kernel_info_request') {
// First send status busy message.
this.parentHeader = data.header;
this.sendStatus(UUID.uuid4(), 'busy');
// Then send the kernel_info_reply message.
this.sendKernelInfoReply(UUID.uuid4(), EXAMPLE_KERNEL_INFO);
// Then send status idle message.
this.sendStatus(UUID.uuid4(), 'idle');
this.parentHeader = undefined;
} else {
const onMessage = this._onMessage;
if (onMessage) {
onMessage(data);
}
}
});
}
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;
});
it('should update the title when the path changes', async () => {
const path = UUID.uuid4() + '.jl';
await context.initialize(true);
await manager.contents.rename(context.path, path);
expect(widget.title.label).to.equal(path);
});
export function createSessionModel(id?: string): Session.IModel {
return {
id: id || UUID.uuid4(),
path: UUID.uuid4(),
name: '',
type: '',
kernel: { id: UUID.uuid4(), name: UUID.uuid4() }
};
}
function randomName() {
return UUID.uuid4().replace(/-/g, '');
}
beforeEach(() => {
const registry = new DocumentRegistry({ textModelFactory });
registry.addWidgetFactory(widgetFactory);
manager = new LoggingManager({ registry });
context = new Context({
manager: services,
factory: textModelFactory,
path: UUID.uuid4()
});
});
function createMessage(
msgType: T['msgType'],
content?: T['content'],
parentId?: string
): T {
let msgId = UUID.uuid4();
if (content === undefined) {
content = {};
}
return {
msgId,
msgType,
parentId,
content,
} as T;
}
function createReply(
msgType: T['msgType'],
content: T['content'],
parentId: string
): T {
let msgId = UUID.uuid4();
return {
msgId,
msgType,
parentId,
content
} as T;
}