mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Remove ApiWrapper from notebook extension (#11224)
* Remove ApiWrapper in notebook extension * delete file * Remove copyrights
This commit is contained in:
@@ -11,7 +11,6 @@ import * as TypeMoq from 'typemoq';
|
||||
import { NotebookCompletionItemProvider } from '../../intellisense/completionItemProvider';
|
||||
import { JupyterNotebookProvider } from '../../jupyter/jupyterNotebookProvider';
|
||||
import { NotebookUtils } from '../../common/notebookUtils';
|
||||
import { ApiWrapper } from '../../common/apiWrapper';
|
||||
import { JupyterNotebookManager } from '../../jupyter/jupyterNotebookManager';
|
||||
import { JupyterSessionManager, JupyterSession } from '../../jupyter/jupyterSessionManager';
|
||||
import { LocalJupyterServerManager } from '../../jupyter/jupyterServerManager';
|
||||
@@ -22,7 +21,6 @@ describe('Completion Item Provider', function () {
|
||||
let notebookProviderMock: TypeMoq.IMock<JupyterNotebookProvider>;
|
||||
let notebookUtils: NotebookUtils;
|
||||
let notebookManager: JupyterNotebookManager;
|
||||
let mockApiWrapper: TypeMoq.IMock<ApiWrapper>;
|
||||
let mockSessionManager: TypeMoq.IMock<JupyterSessionManager>;
|
||||
let mockServerManager: TypeMoq.IMock<LocalJupyterServerManager>;
|
||||
let mockJupyterSession: TypeMoq.IMock<JupyterSession>;
|
||||
@@ -31,8 +29,7 @@ describe('Completion Item Provider', function () {
|
||||
let token: vscode.CancellationToken;
|
||||
|
||||
this.beforeAll(async () => {
|
||||
mockApiWrapper = TypeMoq.Mock.ofType<ApiWrapper>();
|
||||
notebookUtils = new NotebookUtils(new ApiWrapper());
|
||||
notebookUtils = new NotebookUtils();
|
||||
mockServerManager = TypeMoq.Mock.ofType<LocalJupyterServerManager>();
|
||||
testEvent = new vscode.EventEmitter();
|
||||
token = {
|
||||
@@ -47,7 +44,7 @@ describe('Completion Item Provider', function () {
|
||||
mockSessionManager = TypeMoq.Mock.ofType<JupyterSessionManager>();
|
||||
mockJupyterSession = TypeMoq.Mock.ofType<JupyterSession>();
|
||||
kernel = new TestKernel(true, true);
|
||||
notebookManager = new JupyterNotebookManager(mockServerManager.object, mockSessionManager.object, mockApiWrapper.object);
|
||||
notebookManager = new JupyterNotebookManager(mockServerManager.object, mockSessionManager.object);
|
||||
notebookProviderMock = TypeMoq.Mock.ofType<JupyterNotebookProvider>();
|
||||
notebookProviderMock.setup(n => n.getNotebookManager(TypeMoq.It.isAny())).returns(() => Promise.resolve(notebookManager));
|
||||
completionItemProvider = new NotebookCompletionItemProvider(notebookProviderMock.object);
|
||||
|
||||
@@ -7,8 +7,8 @@ import * as azdata from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
import * as should from 'should';
|
||||
import * as TypeMoq from 'typemoq';
|
||||
import * as sinon from 'sinon';
|
||||
|
||||
import { ApiWrapper } from '../../common/apiWrapper';
|
||||
import { AppContext } from '../../common/appContext';
|
||||
import { JupyterController } from '../../jupyter/jupyterController';
|
||||
import { LocalPipPackageManageProvider } from '../../jupyter/localPipPackageManageProvider';
|
||||
@@ -16,24 +16,24 @@ import { MockExtensionContext } from '../common/stubs';
|
||||
import { NotebookUtils } from '../../common/notebookUtils';
|
||||
|
||||
describe('Jupyter Controller', function () {
|
||||
let mockExtensionContext: vscode.ExtensionContext;
|
||||
let appContext: AppContext;
|
||||
let mockExtensionContext: vscode.ExtensionContext = new MockExtensionContext();
|
||||
let appContext = new AppContext(mockExtensionContext);
|
||||
let controller: JupyterController;
|
||||
let mockApiWrapper: TypeMoq.IMock<ApiWrapper>;
|
||||
let connection: azdata.connection.ConnectionProfile;
|
||||
|
||||
this.beforeAll(() => {
|
||||
mockExtensionContext = new MockExtensionContext();
|
||||
connection = new azdata.connection.ConnectionProfile();
|
||||
});
|
||||
let connection: azdata.connection.ConnectionProfile = new azdata.connection.ConnectionProfile();
|
||||
let showErrorMessageSpy: sinon.SinonSpy;
|
||||
|
||||
this.beforeEach(() => {
|
||||
mockApiWrapper = TypeMoq.Mock.ofType<ApiWrapper>();
|
||||
mockApiWrapper.setup(x => x.getCurrentConnection()).returns(() => { return Promise.resolve(connection); });
|
||||
appContext = new AppContext(mockExtensionContext, mockApiWrapper.object);
|
||||
showErrorMessageSpy = sinon.spy(vscode.window, 'showErrorMessage');
|
||||
sinon.stub(azdata.connection, 'getCurrentConnection').returns(Promise.resolve(connection));
|
||||
sinon.stub(azdata.tasks, 'registerTask');
|
||||
sinon.stub(vscode.commands, 'registerCommand');
|
||||
controller = new JupyterController(appContext);
|
||||
});
|
||||
|
||||
this.afterEach(function (): void {
|
||||
sinon.restore();
|
||||
});
|
||||
|
||||
it('should activate new JupyterController successfully', async () => {
|
||||
should(controller.extensionContext).deepEqual(appContext.extensionContext, 'Extension context should be passed through');
|
||||
should(controller.jupyterInstallation).equal(undefined, 'JupyterInstallation should be undefined before controller activation');
|
||||
@@ -65,13 +65,13 @@ describe('Jupyter Controller', function () {
|
||||
|
||||
it('should show error message for doManagePackages before activation', async () => {
|
||||
await controller.doManagePackages();
|
||||
mockApiWrapper.verify(x => x.showErrorMessage(TypeMoq.It.isAny()), TypeMoq.Times.once());
|
||||
should(showErrorMessageSpy.calledOnce).be.true('showErrorMessage should be called');
|
||||
});
|
||||
|
||||
it('should not show error message for doManagePackages after activation', async () => {
|
||||
await controller.activate();
|
||||
await controller.doManagePackages();
|
||||
mockApiWrapper.verify(x => x.showErrorMessage(TypeMoq.It.isAny()), TypeMoq.Times.never());
|
||||
should(showErrorMessageSpy.notCalled).be.true('showErrorMessage should not be called');
|
||||
});
|
||||
|
||||
it('Returns expected values from notebook provider', async () => {
|
||||
@@ -85,7 +85,7 @@ describe('Jupyter Controller', function () {
|
||||
|
||||
it('Returns notebook manager for real notebook editor', async () => {
|
||||
await controller.activate();
|
||||
let notebookUtils = new NotebookUtils(mockApiWrapper.object);
|
||||
let notebookUtils = new NotebookUtils();
|
||||
const notebookEditor = await notebookUtils.newNotebook(undefined);
|
||||
let notebookManager = await controller.notebookProvider.getNotebookManager(notebookEditor.document.uri);
|
||||
should(controller.notebookProvider.notebookManagerCount).equal(1);
|
||||
|
||||
@@ -12,7 +12,6 @@ import 'mocha';
|
||||
import { LocalJupyterServerManager, ServerInstanceFactory, IServerManagerOptions } from '../../jupyter/jupyterServerManager';
|
||||
import { JupyterServerInstallation } from '../../jupyter/jupyterServerInstallation';
|
||||
import { Deferred } from '../../common/promise';
|
||||
import { ApiWrapper } from '../../common/apiWrapper';
|
||||
import { MockExtensionContext } from '../common/stubs';
|
||||
import { JupyterSessionManager } from '../../jupyter/jupyterSessionManager';
|
||||
import { JupyterNotebookManager } from '../../jupyter/jupyterNotebookManager';
|
||||
@@ -28,15 +27,11 @@ describe('Jupyter Notebook Manager', function (): void {
|
||||
let sessionManager: JupyterSessionManager;
|
||||
let notebookManager: JupyterNotebookManager;
|
||||
let deferredInstall: Deferred<void>;
|
||||
let mockApiWrapper: TypeMoq.IMock<ApiWrapper>;
|
||||
let mockExtensionContext: MockExtensionContext;
|
||||
let mockFactory: TypeMoq.IMock<ServerInstanceFactory>;
|
||||
let serverManagerOptions: IServerManagerOptions;
|
||||
beforeEach(() => {
|
||||
mockExtensionContext = new MockExtensionContext();
|
||||
mockApiWrapper = TypeMoq.Mock.ofType(ApiWrapper);
|
||||
mockApiWrapper.setup(a => a.showErrorMessage(TypeMoq.It.isAny()));
|
||||
mockApiWrapper.setup(a => a.getWorkspacePathFromUri(TypeMoq.It.isAny())).returns(() => undefined);
|
||||
mockFactory = TypeMoq.Mock.ofType(ServerInstanceFactory);
|
||||
|
||||
deferredInstall = new Deferred<void>();
|
||||
@@ -48,7 +43,6 @@ describe('Jupyter Notebook Manager', function (): void {
|
||||
documentPath: expectedPath,
|
||||
jupyterInstallation: mockInstall.object,
|
||||
extensionContext: mockExtensionContext,
|
||||
apiWrapper: mockApiWrapper.object,
|
||||
factory: mockFactory.object
|
||||
};
|
||||
serverManager = new LocalJupyterServerManager(serverManagerOptions);
|
||||
@@ -90,7 +84,7 @@ describe('Jupyter Notebook Manager', function (): void {
|
||||
it('Session and server managers should be shutdown/stopped on dispose', async function(): Promise<void> {
|
||||
let sessionManager = TypeMoq.Mock.ofType<JupyterSessionManager>();
|
||||
let serverManager = TypeMoq.Mock.ofType<LocalJupyterServerManager>();
|
||||
notebookManager = new JupyterNotebookManager(serverManager.object, sessionManager.object, mockApiWrapper.object);
|
||||
notebookManager = new JupyterNotebookManager(serverManager.object, sessionManager.object);
|
||||
sessionManager.setup(s => s.shutdownAll()).returns(() => new Promise((resolve) => resolve()));
|
||||
serverManager.setup(s => s.stopServer()).returns(() => new Promise((resolve) => resolve()));
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import { ChildProcess } from 'child_process';
|
||||
import 'mocha';
|
||||
|
||||
import { JupyterServerInstallation } from '../../jupyter/jupyterServerInstallation';
|
||||
import { ApiWrapper } from '../..//common/apiWrapper';
|
||||
import { PerFolderServerInstance, ServerInstanceUtils } from '../../jupyter/serverInstance';
|
||||
import { MockOutputChannel } from '../common/stubs';
|
||||
import * as testUtils from '../common/testUtils';
|
||||
@@ -25,14 +24,10 @@ describe('Jupyter server instance', function (): void {
|
||||
let expectedPath = 'mydir/notebook.ipynb';
|
||||
let mockInstall: TypeMoq.IMock<JupyterServerInstallation>;
|
||||
let mockOutputChannel: TypeMoq.IMock<MockOutputChannel>;
|
||||
let mockApiWrapper: TypeMoq.IMock<ApiWrapper>;
|
||||
let mockUtils: TypeMoq.IMock<ServerInstanceUtils>;
|
||||
let serverInstance: PerFolderServerInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
mockApiWrapper = TypeMoq.Mock.ofType(ApiWrapper);
|
||||
mockApiWrapper.setup(a => a.showErrorMessage(TypeMoq.It.isAny()));
|
||||
mockApiWrapper.setup(a => a.getWorkspacePathFromUri(TypeMoq.It.isAny())).returns(() => undefined);
|
||||
mockInstall = TypeMoq.Mock.ofType(JupyterServerInstallation, undefined, undefined, '/root');
|
||||
mockOutputChannel = TypeMoq.Mock.ofType(MockOutputChannel);
|
||||
mockInstall.setup(i => i.outputChannel).returns(() => mockOutputChannel.object);
|
||||
|
||||
@@ -13,7 +13,6 @@ import { JupyterServerInstanceStub } from '../common';
|
||||
import { LocalJupyterServerManager, ServerInstanceFactory } from '../../jupyter/jupyterServerManager';
|
||||
import { JupyterServerInstallation } from '../../jupyter/jupyterServerInstallation';
|
||||
import { Deferred } from '../../common/promise';
|
||||
import { ApiWrapper } from '../../common/apiWrapper';
|
||||
import * as testUtils from '../common/testUtils';
|
||||
import { IServerInstance } from '../../jupyter/common';
|
||||
import { MockExtensionContext } from '../common/stubs';
|
||||
@@ -26,14 +25,10 @@ describe('Local Jupyter Server Manager', function (): void {
|
||||
let expectedPath = 'my/notebook.ipynb';
|
||||
let serverManager: LocalJupyterServerManager;
|
||||
let deferredInstall: Deferred<void>;
|
||||
let mockApiWrapper: TypeMoq.IMock<ApiWrapper>;
|
||||
let mockExtensionContext: MockExtensionContext;
|
||||
let mockFactory: TypeMoq.IMock<ServerInstanceFactory>;
|
||||
beforeEach(() => {
|
||||
mockExtensionContext = new MockExtensionContext();
|
||||
mockApiWrapper = TypeMoq.Mock.ofType(ApiWrapper);
|
||||
mockApiWrapper.setup(a => a.showErrorMessage(TypeMoq.It.isAny()));
|
||||
mockApiWrapper.setup(a => a.getWorkspacePathFromUri(TypeMoq.It.isAny())).returns(() => undefined);
|
||||
mockFactory = TypeMoq.Mock.ofType(ServerInstanceFactory);
|
||||
|
||||
deferredInstall = new Deferred<void>();
|
||||
@@ -45,7 +40,6 @@ describe('Local Jupyter Server Manager', function (): void {
|
||||
documentPath: expectedPath,
|
||||
jupyterInstallation: mockInstall.object,
|
||||
extensionContext: mockExtensionContext,
|
||||
apiWrapper: mockApiWrapper.object,
|
||||
factory: mockFactory.object
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user