mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-01 09:35:41 -05:00
Initial implementation for VSCode Notebook support (#17885)
This commit is contained in:
@@ -34,6 +34,7 @@ import { ServiceCollection } from 'vs/platform/instantiation/common/serviceColle
|
||||
import { ExecuteManagerStub, SerializationManagerStub } from 'sql/workbench/contrib/notebook/test/stubs';
|
||||
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { UndoRedoService } from 'vs/platform/undoRedo/common/undoRedoService';
|
||||
import { NBFORMAT, NBFORMAT_MINOR } from 'sql/workbench/common/constants';
|
||||
|
||||
suite('CellToolbarActions', function (): void {
|
||||
suite('removeDuplicatedAndStartingSeparators', function (): void {
|
||||
@@ -211,8 +212,8 @@ export async function createandLoadNotebookModel(codeContent?: nb.INotebookConte
|
||||
display_name: 'Python 3'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
|
||||
let serviceCollection = new ServiceCollection();
|
||||
|
||||
@@ -31,6 +31,7 @@ import { Separator } from 'vs/base/common/actions';
|
||||
import { INotebookView, INotebookViews } from 'sql/workbench/services/notebook/browser/notebookViews/notebookViews';
|
||||
import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys';
|
||||
import { ITelemetryEventProperties } from 'sql/platform/telemetry/common/telemetry';
|
||||
import { NBFORMAT, NBFORMAT_MINOR } from 'sql/workbench/common/constants';
|
||||
|
||||
class TestClientSession extends ClientSessionStub {
|
||||
private _errorState: boolean = false;
|
||||
@@ -280,8 +281,8 @@ suite('Notebook Actions', function (): void {
|
||||
display_name: 'Python 3'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
|
||||
let mockNotification = TypeMoq.Mock.ofType<INotificationService>(TestNotificationService);
|
||||
@@ -324,8 +325,8 @@ suite('Notebook Actions', function (): void {
|
||||
display_name: 'Python 3'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
let expectedMsg: string = noParameterCell;
|
||||
|
||||
@@ -365,8 +366,8 @@ suite('Notebook Actions', function (): void {
|
||||
display_name: 'Python 3'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
let expectedMsg: string = noParametersInCell;
|
||||
|
||||
@@ -410,8 +411,8 @@ suite('Notebook Actions', function (): void {
|
||||
display_name: 'Python 3'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
let expectedMsg: string = noParametersInCell;
|
||||
|
||||
@@ -456,8 +457,8 @@ suite('Notebook Actions', function (): void {
|
||||
display_name: 'Python 3'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
let expectedMsg: string = noParametersInCell;
|
||||
|
||||
@@ -505,8 +506,8 @@ suite('Notebook Actions', function (): void {
|
||||
display_name: 'SQL'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
let expectedMsg: string = kernelNotSupported;
|
||||
|
||||
|
||||
@@ -36,12 +36,12 @@ suite('Notebook Input', function (): void {
|
||||
const mockNotebookService = TypeMoq.Mock.ofType<INotebookService>(NotebookServiceStub);
|
||||
mockNotebookService.setup(s => s.getProvidersForFileType(TypeMoq.It.isAny())).returns(() => [testProvider]);
|
||||
mockNotebookService.setup(s => s.getStandardKernelsForProvider(TypeMoq.It.isAny())).returns(() => {
|
||||
return [{
|
||||
return Promise.resolve([{
|
||||
name: 'TestName',
|
||||
displayName: 'TestDisplayName',
|
||||
connectionProviderIds: ['TestId'],
|
||||
notebookProvider: testProvider
|
||||
}];
|
||||
}]);
|
||||
});
|
||||
let testManager: ISerializationManager = {
|
||||
providerId: testProvider,
|
||||
|
||||
@@ -222,7 +222,8 @@ suite.skip('NotebookService:', function (): void {
|
||||
assert.strictEqual(notebookService.listNotebookEditors().length, 0, 'No notebook editors should be listed');
|
||||
assert.strictEqual(notebookService.getMimeRegistry().mimeTypes.length, 15, 'MIME Types need to have appropriate tests when added or removed');
|
||||
assert.deepStrictEqual(notebookService.getProvidersForFileType('.ipynb'), ['sql'], 'sql provider should be registered for ipynb extension');
|
||||
assert.strictEqual(notebookService.getStandardKernelsForProvider('sql').length, 1, 'SQL kernel should be provided by default');
|
||||
let standardKernels = await notebookService.getStandardKernelsForProvider('sql');
|
||||
assert.strictEqual(standardKernels.length, 1, 'SQL kernel should be provided by default');
|
||||
assert.strictEqual(notebookService.getStandardKernelsForProvider('otherProvider'), undefined, 'Other provider should not have kernels since it has not been added as a provider');
|
||||
assert.deepStrictEqual(notebookService.getSupportedFileExtensions(), ['.ipynb'], 'IPYNB file extension should be supported by default');
|
||||
await notebookService.registrationComplete;
|
||||
@@ -248,7 +249,8 @@ suite.skip('NotebookService:', function (): void {
|
||||
|
||||
assert.deepStrictEqual(notebookService.getProvidersForFileType('.ipynb'), ['sql', 'otherProvider'], 'otherProvider should also be registered for ipynb extension');
|
||||
assert.deepStrictEqual(notebookService.getSupportedFileExtensions(), ['.ipynb'], 'Only IPYNB should be registered as supported file extension');
|
||||
assert.strictEqual(notebookService.getStandardKernelsForProvider('otherProvider').length, 1, 'otherProvider kernel info could not be found');
|
||||
let standardKernels = await notebookService.getStandardKernelsForProvider('otherProvider');
|
||||
assert.strictEqual(standardKernels.length, 1, 'otherProvider kernel info could not be found');
|
||||
assert.deepStrictEqual(notebookService.getStandardKernelsForProvider('otherProvider')[0], otherProviderRegistration.standardKernels[0], 'otherProviderRegistration standard kernels does not match');
|
||||
});
|
||||
|
||||
@@ -557,7 +559,7 @@ suite.skip('NotebookService:', function (): void {
|
||||
await notebookService.registrationComplete;
|
||||
queryManagementService.onHandlerAddedEmitter.fire(SQL_NOTEBOOK_PROVIDER);
|
||||
const connectionTypes = queryManagementService.getRegisteredProviders();
|
||||
const kernels = notebookService.getStandardKernelsForProvider(SQL_NOTEBOOK_PROVIDER);
|
||||
const kernels = await notebookService.getStandardKernelsForProvider(SQL_NOTEBOOK_PROVIDER);
|
||||
for (const kernel of kernels) {
|
||||
assert.strictEqual(kernel.name, notebookConstants.SQL, `kernel name for standard kernels should be ${notebookConstants.SQL}`);
|
||||
assert.strictEqual(kernel.displayName, notebookConstants.SQL, `kernel displayName for standard kernels should be ${notebookConstants.SQL}`);
|
||||
|
||||
@@ -33,6 +33,8 @@ import { TestConfigurationService } from 'sql/platform/connection/test/common/te
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { NotebookViewModel } from 'sql/workbench/services/notebook/browser/notebookViews/notebookViewModel';
|
||||
import { isUndefinedOrNull } from 'vs/base/common/types';
|
||||
import { SQL_NOTEBOOK_PROVIDER } from 'sql/workbench/services/notebook/browser/notebookService';
|
||||
import { NBFORMAT, NBFORMAT_MINOR } from 'sql/workbench/common/constants';
|
||||
|
||||
let initialNotebookContent: nb.INotebookContents = {
|
||||
cells: [{
|
||||
@@ -52,8 +54,8 @@ let initialNotebookContent: nb.INotebookContents = {
|
||||
language: 'sql'
|
||||
},
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
|
||||
let notebookContentWithoutMeta: nb.INotebookContents = {
|
||||
@@ -67,8 +69,8 @@ let notebookContentWithoutMeta: nb.INotebookContents = {
|
||||
execution_count: 1
|
||||
}],
|
||||
metadata: {},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
|
||||
let defaultUri = URI.file('/some/path.ipynb');
|
||||
@@ -240,6 +242,7 @@ suite('NotebookViewModel', function (): void {
|
||||
|
||||
function setupServices() {
|
||||
mockSessionManager = TypeMoq.Mock.ofType(SessionManager);
|
||||
executeManagers[0].providerId = SQL_NOTEBOOK_PROVIDER;
|
||||
executeManagers[0].sessionManager = mockSessionManager.object;
|
||||
notificationService = TypeMoq.Mock.ofType<INotificationService>(TestNotificationService, TypeMoq.MockBehavior.Loose);
|
||||
capabilitiesService = TypeMoq.Mock.ofType<ICapabilitiesService>(TestCapabilitiesService);
|
||||
|
||||
@@ -33,6 +33,8 @@ import { TestStorageService } from 'vs/workbench/test/common/workbenchTestServic
|
||||
import sinon = require('sinon');
|
||||
import { InsertCellsModal } from 'sql/workbench/contrib/notebook/browser/notebookViews/insertCellsModal';
|
||||
import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKeybindingService';
|
||||
import { SQL_NOTEBOOK_PROVIDER } from 'sql/workbench/services/notebook/browser/notebookService';
|
||||
import { NBFORMAT, NBFORMAT_MINOR } from 'sql/workbench/common/constants';
|
||||
|
||||
let initialNotebookContent: nb.INotebookContents = {
|
||||
cells: [{
|
||||
@@ -52,8 +54,8 @@ let initialNotebookContent: nb.INotebookContents = {
|
||||
language: 'sql'
|
||||
},
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
|
||||
suite('Notebook Views Actions', function (): void {
|
||||
@@ -165,6 +167,7 @@ suite('Notebook Views Actions', function (): void {
|
||||
|
||||
function setupServices() {
|
||||
mockSessionManager = TypeMoq.Mock.ofType(SessionManager);
|
||||
executeManagers[0].providerId = SQL_NOTEBOOK_PROVIDER;
|
||||
executeManagers[0].sessionManager = mockSessionManager.object;
|
||||
notificationService = TypeMoq.Mock.ofType<INotificationService>(TestNotificationService, TypeMoq.MockBehavior.Loose);
|
||||
capabilitiesService = TypeMoq.Mock.ofType<ICapabilitiesService>(TestCapabilitiesService);
|
||||
|
||||
@@ -35,6 +35,8 @@ import { TestDialogService } from 'vs/platform/dialogs/test/common/testDialogSer
|
||||
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { UndoRedoService } from 'vs/platform/undoRedo/common/undoRedoService';
|
||||
import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo';
|
||||
import { SQL_NOTEBOOK_PROVIDER } from 'sql/workbench/services/notebook/browser/notebookService';
|
||||
import { NBFORMAT, NBFORMAT_MINOR } from 'sql/workbench/common/constants';
|
||||
|
||||
let initialNotebookContent: nb.INotebookContents = {
|
||||
cells: [{
|
||||
@@ -54,8 +56,8 @@ let initialNotebookContent: nb.INotebookContents = {
|
||||
language: 'sql'
|
||||
},
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
|
||||
let defaultUri = URI.file('/some/path.ipynb');
|
||||
@@ -151,6 +153,7 @@ suite('NotebookViews', function (): void {
|
||||
|
||||
function setupServices() {
|
||||
mockSessionManager = TypeMoq.Mock.ofType(SessionManager);
|
||||
executeManagers[0].providerId = SQL_NOTEBOOK_PROVIDER;
|
||||
executeManagers[0].sessionManager = mockSessionManager.object;
|
||||
notificationService = TypeMoq.Mock.ofType<INotificationService>(TestNotificationService, TypeMoq.MockBehavior.Loose);
|
||||
capabilitiesService = TypeMoq.Mock.ofType<ICapabilitiesService>(TestCapabilitiesService);
|
||||
|
||||
@@ -17,6 +17,7 @@ import { TestFileService } from 'vs/workbench/test/browser/workbenchTestServices
|
||||
import { IFileService, IReadFileOptions, IFileContent, IWriteFileOptions, IFileStatWithMetadata } from 'vs/platform/files/common/files';
|
||||
import { VSBuffer, VSBufferReadable } from 'vs/base/common/buffer';
|
||||
import { promisify } from 'util';
|
||||
import { NBFORMAT, NBFORMAT_MINOR } from 'sql/workbench/common/constants';
|
||||
|
||||
let expectedNotebookContent: nb.INotebookContents = {
|
||||
cells: [{
|
||||
@@ -32,8 +33,8 @@ let expectedNotebookContent: nb.INotebookContents = {
|
||||
display_name: 'SQL'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 2
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
|
||||
let notebookContentString = JSON.stringify(expectedNotebookContent);
|
||||
@@ -105,8 +106,8 @@ suite('Local Content Manager', function (): void {
|
||||
display_name: 'SQL'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 2
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
let mimeContentString = JSON.stringify(mimeNotebook);
|
||||
// when I read the content
|
||||
@@ -155,8 +156,8 @@ suite('Local Content Manager', function (): void {
|
||||
display_name: 'SQL'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 2
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
let markdownNotebookContent = JSON.stringify(expectedNotebookMarkdownContent);
|
||||
// verify that notebooks support markdown cells
|
||||
@@ -189,8 +190,8 @@ suite('Local Content Manager', function (): void {
|
||||
display_name: 'Python 3'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 2
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
let streamOutputContent = JSON.stringify(expectedNotebookStreamOutputContent);
|
||||
// Verify that the stream output type is supported
|
||||
|
||||
@@ -27,11 +27,13 @@ import { InstantiationService } from 'vs/platform/instantiation/common/instantia
|
||||
import { ClientSession } from 'sql/workbench/services/notebook/browser/models/clientSession';
|
||||
import { TestStorageService } from 'vs/workbench/test/common/workbenchTestServices';
|
||||
import { NotebookEditorContentLoader } from 'sql/workbench/contrib/notebook/browser/models/notebookInput';
|
||||
import { NotebookRange } from 'sql/workbench/services/notebook/browser/notebookService';
|
||||
import { NotebookRange, SQL_NOTEBOOK_PROVIDER } from 'sql/workbench/services/notebook/browser/notebookService';
|
||||
import { NotebookMarkdownRenderer } from 'sql/workbench/contrib/notebook/browser/outputs/notebookMarkdown';
|
||||
import { NullAdsTelemetryService } from 'sql/platform/telemetry/common/adsTelemetryService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { TestConfigurationService } from 'sql/platform/connection/test/common/testConfigurationService';
|
||||
import { SessionManager } from 'sql/workbench/contrib/notebook/test/emptySessionClasses';
|
||||
import { NBFORMAT, NBFORMAT_MINOR } from 'sql/workbench/common/constants';
|
||||
|
||||
let expectedNotebookContent: nb.INotebookContents = {
|
||||
cells: [{
|
||||
@@ -52,8 +54,8 @@ let expectedNotebookContent: nb.INotebookContents = {
|
||||
display_name: 'SQL'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
|
||||
let defaultUri = URI.file('/some/path.ipynb');
|
||||
@@ -78,6 +80,9 @@ suite('Notebook Find Model', function (): void {
|
||||
let configurationService: IConfigurationService;
|
||||
|
||||
setup(async () => {
|
||||
let mockSessionManager = TypeMoq.Mock.ofType(SessionManager);
|
||||
executeManagers[0].providerId = SQL_NOTEBOOK_PROVIDER;
|
||||
executeManagers[0].sessionManager = mockSessionManager.object;
|
||||
sessionReady = new Deferred<void>();
|
||||
notificationService = TypeMoq.Mock.ofType<INotificationService>(TestNotificationService, TypeMoq.MockBehavior.Loose);
|
||||
capabilitiesService = TypeMoq.Mock.ofType<ICapabilitiesService>(TestCapabilitiesService);
|
||||
@@ -195,8 +200,8 @@ suite('Notebook Find Model', function (): void {
|
||||
display_name: 'SQL'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
await initNotebookModel(markdownContent);
|
||||
|
||||
@@ -228,8 +233,8 @@ suite('Notebook Find Model', function (): void {
|
||||
display_name: 'Python'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
await initNotebookModel(codeContent);
|
||||
//initialize find
|
||||
@@ -254,8 +259,8 @@ suite('Notebook Find Model', function (): void {
|
||||
display_name: 'Python'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
await initNotebookModel(codeContent);
|
||||
//initialize find
|
||||
@@ -315,8 +320,8 @@ suite('Notebook Find Model', function (): void {
|
||||
display_name: 'Python'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
await initNotebookModel(codeContent);
|
||||
//initialize find
|
||||
@@ -348,8 +353,8 @@ suite('Notebook Find Model', function (): void {
|
||||
display_name: 'Python'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
await initNotebookModel(codeContent);
|
||||
//initialize find
|
||||
@@ -380,8 +385,8 @@ suite('Notebook Find Model', function (): void {
|
||||
display_name: 'SQL'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
await initNotebookModel(markdownContent);
|
||||
|
||||
@@ -435,7 +440,7 @@ suite('Notebook Find Model', function (): void {
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
await initNotebookModel(cellContent);
|
||||
|
||||
@@ -546,7 +551,7 @@ suite('Notebook Find Model', function (): void {
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
max_find_count = 4;
|
||||
await initNotebookModel(cellContent);
|
||||
|
||||
@@ -42,6 +42,8 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
|
||||
import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo';
|
||||
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { UndoRedoService } from 'vs/platform/undoRedo/common/undoRedoService';
|
||||
import { SQL_NOTEBOOK_PROVIDER } from 'sql/workbench/services/notebook/browser/notebookService';
|
||||
import { NBFORMAT, NBFORMAT_MINOR } from 'sql/workbench/common/constants';
|
||||
|
||||
let expectedNotebookContent: nb.INotebookContents = {
|
||||
cells: [{
|
||||
@@ -64,8 +66,8 @@ let expectedNotebookContent: nb.INotebookContents = {
|
||||
name: 'sql'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
|
||||
let expectedNotebookContentOneCell: nb.INotebookContents = {
|
||||
@@ -82,8 +84,8 @@ let expectedNotebookContentOneCell: nb.INotebookContents = {
|
||||
display_name: 'SQL'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
|
||||
let expectedKernelAliasNotebookContentOneCell: nb.INotebookContents = {
|
||||
@@ -103,8 +105,8 @@ let expectedKernelAliasNotebookContentOneCell: nb.INotebookContents = {
|
||||
version: ''
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
|
||||
let expectedParameterizedNotebookContent: nb.INotebookContents = {
|
||||
@@ -126,8 +128,8 @@ let expectedParameterizedNotebookContent: nb.INotebookContents = {
|
||||
display_name: 'Python 3'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
|
||||
let defaultUri = URI.file('/some/path.ipynb');
|
||||
@@ -154,6 +156,7 @@ suite('notebook model', function (): void {
|
||||
const logService = new NullLogService();
|
||||
setup(() => {
|
||||
mockSessionManager = TypeMoq.Mock.ofType(SessionManager);
|
||||
executeManagers[0].providerId = SQL_NOTEBOOK_PROVIDER;
|
||||
executeManagers[0].sessionManager = mockSessionManager.object;
|
||||
sessionReady = new Deferred<void>();
|
||||
notificationService = TypeMoq.Mock.ofType<INotificationService>(TestNotificationService, TypeMoq.MockBehavior.Loose);
|
||||
@@ -207,8 +210,8 @@ suite('notebook model', function (): void {
|
||||
display_name: 'SQL'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
|
||||
let mockContentManager = TypeMoq.Mock.ofType(NotebookEditorContentLoader);
|
||||
@@ -307,9 +310,9 @@ suite('notebook model', function (): void {
|
||||
|
||||
// Check that the getters return the correct values
|
||||
assert.strictEqual(model.executeManagers.length, 2, 'There should be 2 notebook managers');
|
||||
assert(!isUndefinedOrNull(model.getExecuteManager('SQL')), 'SQL notebook manager is not defined');
|
||||
assert(!isUndefinedOrNull(model.getExecuteManager('jupyter')), 'Jupyter notebook manager is not defined');
|
||||
assert(isUndefinedOrNull(model.getExecuteManager('foo')), 'foo notebook manager is incorrectly defined');
|
||||
assert(model.executeManagers.some(m => m.providerId === 'SQL'), 'SQL notebook manager should be defined');
|
||||
assert(model.executeManagers.some(m => m.providerId === 'jupyter'), 'Jupyter notebook manager should be defined');
|
||||
assert(model.executeManagers.every(m => m.providerId !== 'foo'), 'foo notebook manager should not be defined');
|
||||
|
||||
// Check other properties to ensure that they're returning as expected
|
||||
// No server manager was passed into the notebook manager stub, so expect hasServerManager to return false
|
||||
@@ -626,8 +629,8 @@ suite('notebook model', function (): void {
|
||||
name: 'sql'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
let mockContentManager = TypeMoq.Mock.ofType(NotebookEditorContentLoader);
|
||||
mockContentManager.setup(c => c.loadContent()).returns(() => Promise.resolve(expectedNotebookContentSplitCells));
|
||||
@@ -905,8 +908,8 @@ suite('notebook model', function (): void {
|
||||
metadata: {
|
||||
connection_name: connectionName
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
let mockContentManager = TypeMoq.Mock.ofType(NotebookEditorContentLoader);
|
||||
mockContentManager.setup(c => c.loadContent()).returns(() => Promise.resolve(notebook));
|
||||
@@ -955,8 +958,8 @@ suite('notebook model', function (): void {
|
||||
metadata: {
|
||||
multi_connection_mode: true
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
nbformat: NBFORMAT,
|
||||
nbformat_minor: NBFORMAT_MINOR
|
||||
};
|
||||
let mockContentManager = TypeMoq.Mock.ofType(NotebookEditorContentLoader);
|
||||
mockContentManager.setup(c => c.loadContent()).returns(() => Promise.resolve(notebook));
|
||||
|
||||
@@ -41,13 +41,13 @@ suite('notebookUtils', function (): void {
|
||||
|
||||
// getStandardKernelsForProvider
|
||||
let returnHandler = (provider) => {
|
||||
let result = undefined;
|
||||
if (provider === testProvider) {
|
||||
return [testKernel];
|
||||
result = [testKernel];
|
||||
} else if (provider === SQL_NOTEBOOK_PROVIDER) {
|
||||
return [sqlStandardKernel];
|
||||
} else {
|
||||
return undefined;
|
||||
result = [sqlStandardKernel];
|
||||
}
|
||||
return Promise.resolve(result);
|
||||
};
|
||||
mockNotebookService.setup(n => n.getStandardKernelsForProvider(TypeMoq.It.isAnyString())).returns(returnHandler);
|
||||
mockNotebookService.setup(n => n.getStandardKernelsForProvider(TypeMoq.It.isAnyString())).returns(returnHandler);
|
||||
@@ -91,19 +91,19 @@ suite('notebookUtils', function (): void {
|
||||
test('getStandardKernelsForProvider Test', async function (): Promise<void> {
|
||||
setupMockNotebookService();
|
||||
|
||||
let result = getStandardKernelsForProvider(undefined, undefined);
|
||||
let result = await getStandardKernelsForProvider(undefined, undefined);
|
||||
assert.deepStrictEqual(result, []);
|
||||
|
||||
result = getStandardKernelsForProvider(undefined, mockNotebookService.object);
|
||||
result = await getStandardKernelsForProvider(undefined, mockNotebookService.object);
|
||||
assert.deepStrictEqual(result, []);
|
||||
|
||||
result = getStandardKernelsForProvider('testProvider', undefined);
|
||||
result = await getStandardKernelsForProvider('testProvider', undefined);
|
||||
assert.deepStrictEqual(result, []);
|
||||
|
||||
result = getStandardKernelsForProvider('NotARealProvider', mockNotebookService.object);
|
||||
result = await getStandardKernelsForProvider('NotARealProvider', mockNotebookService.object);
|
||||
assert.deepStrictEqual(result, [Object.assign({ notebookProvider: 'NotARealProvider' }, sqlStandardKernel)]);
|
||||
|
||||
result = getStandardKernelsForProvider('testProvider', mockNotebookService.object);
|
||||
result = await getStandardKernelsForProvider('testProvider', mockNotebookService.object);
|
||||
assert.deepStrictEqual(result, [<IStandardKernelWithProvider>{
|
||||
name: 'testName',
|
||||
displayName: 'testDisplayName',
|
||||
|
||||
@@ -281,7 +281,7 @@ export class NotebookServiceStub implements INotebookService {
|
||||
getProvidersForFileType(fileType: string): string[] {
|
||||
return [];
|
||||
}
|
||||
getStandardKernelsForProvider(provider: string): nb.IStandardKernel[] {
|
||||
getStandardKernelsForProvider(provider: string): Promise<nb.IStandardKernel[]> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
getOrCreateSerializationManager(providerId: string, uri: URI): Promise<ISerializationManager> {
|
||||
|
||||
Reference in New Issue
Block a user