mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Integrate first SQL Notebooks Bits into Master (#3679)
* First crack tsql notebook (no output rendered yet) * getting messages back * intellisense working first cell, no connection errors * sql notebook cell output functioning * Latest SQL noteobook changes * Undo change to launch.json * Plumbing providers through * Kernels shown from multiple providers, can switch between them. No mementos yet * Ensure we have a feature flag for SQL notebooks, ensure existing functionality still works * Fix tslint duplicate imports issue * Addressing PR comments * second round of PR feedback to cleanup notebook service manager code * merge latest from master
This commit is contained in:
@@ -30,7 +30,7 @@ export class NotebookModelStub implements INotebookModel {
|
||||
get clientSession(): IClientSession {
|
||||
throw new Error('method not implemented.');
|
||||
}
|
||||
get notebookManager(): INotebookManager {
|
||||
get notebookManagers(): INotebookManager[] {
|
||||
throw new Error('method not implemented.');
|
||||
}
|
||||
get kernelChanged(): Event<nb.IKernelChangedArgs> {
|
||||
@@ -53,6 +53,9 @@ export class NotebookModelStub implements INotebookModel {
|
||||
get contexts(): IDefaultConnection {
|
||||
throw new Error('method not implemented.');
|
||||
}
|
||||
get providerId(): string {
|
||||
throw new Error('method not implemented.');
|
||||
}
|
||||
changeKernel(displayName: string): void {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ let mockModelFactory: TypeMoq.Mock<ModelFactory>;
|
||||
let notificationService: TypeMoq.Mock<INotificationService>;
|
||||
|
||||
describe('notebook model', function(): void {
|
||||
let notebookManager = new NotebookManagerStub();
|
||||
let notebookManagers = [new NotebookManagerStub()];
|
||||
let memento: TypeMoq.Mock<Memento>;
|
||||
let queryConnectionService: TypeMoq.Mock<ConnectionManagementService>;
|
||||
let defaultModelOptions: INotebookModelOptions;
|
||||
@@ -87,9 +87,10 @@ describe('notebook model', function(): void {
|
||||
defaultModelOptions = {
|
||||
notebookUri: defaultUri,
|
||||
factory: new ModelFactory(),
|
||||
notebookManager,
|
||||
notebookManagers,
|
||||
notificationService: notificationService.object,
|
||||
connectionService: queryConnectionService.object };
|
||||
connectionService: queryConnectionService.object,
|
||||
providerId: 'jupyter' };
|
||||
mockClientSession = TypeMoq.Mock.ofType(ClientSession, undefined, defaultModelOptions);
|
||||
mockClientSession.setup(c => c.initialize(TypeMoq.It.isAny())).returns(() => {
|
||||
return Promise.resolve();
|
||||
@@ -118,7 +119,7 @@ describe('notebook model', function(): void {
|
||||
|
||||
let mockContentManager = TypeMoq.Mock.ofType(LocalContentManager);
|
||||
mockContentManager.setup(c => c.getNotebookContents(TypeMoq.It.isAny())).returns(() => Promise.resolve(emptyNotebook));
|
||||
notebookManager.contentManager = mockContentManager.object;
|
||||
notebookManagers[0].contentManager = mockContentManager.object;
|
||||
|
||||
// When I initialize the model
|
||||
let model = new NotebookModel(defaultModelOptions);
|
||||
@@ -134,7 +135,7 @@ describe('notebook model', function(): void {
|
||||
let error = new Error('File not found');
|
||||
let mockContentManager = TypeMoq.Mock.ofType(LocalContentManager);
|
||||
mockContentManager.setup(c => c.getNotebookContents(TypeMoq.It.isAny())).throws(error);
|
||||
notebookManager.contentManager = mockContentManager.object;
|
||||
notebookManagers[0].contentManager = mockContentManager.object;
|
||||
|
||||
// When I initalize the model
|
||||
// Then it should throw
|
||||
@@ -148,7 +149,7 @@ describe('notebook model', function(): void {
|
||||
// Given a notebook with 2 cells
|
||||
let mockContentManager = TypeMoq.Mock.ofType(LocalContentManager);
|
||||
mockContentManager.setup(c => c.getNotebookContents(TypeMoq.It.isAny())).returns(() => Promise.resolve(expectedNotebookContent));
|
||||
notebookManager.contentManager = mockContentManager.object;
|
||||
notebookManagers[0].contentManager = mockContentManager.object;
|
||||
|
||||
// When I initalize the model
|
||||
let model = new NotebookModel(defaultModelOptions);
|
||||
@@ -163,7 +164,7 @@ describe('notebook model', function(): void {
|
||||
it('Should load contents but then go to error state if client session startup fails', async function(): Promise<void> {
|
||||
let mockContentManager = TypeMoq.Mock.ofType(LocalContentManager);
|
||||
mockContentManager.setup(c => c.getNotebookContents(TypeMoq.It.isAny())).returns(() => Promise.resolve(expectedNotebookContentOneCell));
|
||||
notebookManager.contentManager = mockContentManager.object;
|
||||
notebookManagers[0].contentManager = mockContentManager.object;
|
||||
|
||||
// Given I have a session that fails to start
|
||||
mockClientSession.setup(c => c.isInErrorState).returns(() => true);
|
||||
@@ -192,7 +193,7 @@ describe('notebook model', function(): void {
|
||||
it('Should not be in error state if client session initialization succeeds', async function(): Promise<void> {
|
||||
let mockContentManager = TypeMoq.Mock.ofType(LocalContentManager);
|
||||
mockContentManager.setup(c => c.getNotebookContents(TypeMoq.It.isAny())).returns(() => Promise.resolve(expectedNotebookContentOneCell));
|
||||
notebookManager.contentManager = mockContentManager.object;
|
||||
notebookManagers[0].contentManager = mockContentManager.object;
|
||||
let kernelChangedEmitter: Emitter<nb.IKernelChangedArgs> = new Emitter<nb.IKernelChangedArgs>();
|
||||
|
||||
mockClientSession.setup(c => c.isInErrorState).returns(() => false);
|
||||
|
||||
@@ -122,6 +122,7 @@ suite('ExtHostNotebook Tests', () => {
|
||||
|
||||
class NotebookProviderStub implements sqlops.nb.NotebookProvider {
|
||||
providerId: string = 'TestProvider';
|
||||
standardKernels: string[] = ['fakeKernel'];
|
||||
|
||||
getNotebookManager(notebookUri: vscode.Uri): Thenable<sqlops.nb.NotebookManager> {
|
||||
throw new Error('Method not implemented.');
|
||||
|
||||
Reference in New Issue
Block a user