Skip to content
Merged
Prev Previous commit
Next Next commit
Fix errors in tests
  • Loading branch information
DonJayamanne committed May 8, 2018
commit 8374dc77bfb8668c45ec2fcff3667af15b94f381
4 changes: 3 additions & 1 deletion src/test/common/terminals/activation.conda.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

// tslint:disable:max-func-body-length no-any

import { expect } from 'chai';
import * as path from 'path';
import * as TypeMoq from 'typemoq';
Expand All @@ -16,7 +18,6 @@ import { IConfigurationService, IDisposableRegistry, IPythonSettings, ITerminalS
import { ICondaService } from '../../../client/interpreter/contracts';
import { IServiceContainer } from '../../../client/ioc/types';

// tslint:disable-next-line:max-func-body-length
suite('Terminal Environment Activation conda', () => {
let terminalHelper: TerminalHelper;
let disposables: Disposable[] = [];
Expand All @@ -38,6 +39,7 @@ suite('Terminal Environment Activation conda', () => {
platformService = TypeMoq.Mock.ofType<IPlatformService>();
processService = TypeMoq.Mock.ofType<IProcessService>();
condaService = TypeMoq.Mock.ofType<ICondaService>();
processService.setup((x: any) => x.then).returns(() => undefined);
procServiceFactory = TypeMoq.Mock.ofType<IProcessServiceFactory>();
procServiceFactory.setup(p => p.create(TypeMoq.It.isAny())).returns(() => Promise.resolve(processService.object));

Expand Down
4 changes: 2 additions & 2 deletions src/test/interpreters/condaService.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// tslint:disable:no-require-imports no-var-requires no-any max-func-body-length
import * as assert from 'assert';
import { expect } from 'chai';
import { EOL } from 'os';
Expand All @@ -12,12 +13,10 @@ import { CondaService, KNOWN_CONDA_LOCATIONS } from '../../client/interpreter/lo
import { IServiceContainer } from '../../client/ioc/types';
import { MockState } from './mocks';

// tslint:disable-next-line:no-require-imports no-var-requires
const untildify: (value: string) => string = require('untildify');

const environmentsPath = path.join(__dirname, '..', '..', '..', 'src', 'test', 'pythonFiles', 'environments');

// tslint:disable-next-line:max-func-body-length
suite('Interpreters Conda Service', () => {
let processService: TypeMoq.IMock<IProcessService>;
let platformService: TypeMoq.IMock<IPlatformService>;
Expand All @@ -33,6 +32,7 @@ suite('Interpreters Conda Service', () => {
registryInterpreterLocatorService = TypeMoq.Mock.ofType<IInterpreterLocatorService>();
fileSystem = TypeMoq.Mock.ofType<IFileSystem>();
procServiceFactory = TypeMoq.Mock.ofType<IProcessServiceFactory>();
processService.setup((x: any) => x.then).returns(() => undefined);
procServiceFactory.setup(p => p.create(TypeMoq.It.isAny())).returns(() => Promise.resolve(processService.object));

serviceContainer = TypeMoq.Mock.ofType<IServiceContainer>();
Expand Down
12 changes: 7 additions & 5 deletions src/test/interpreters/currentPathService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@

'use strict';

// tslint:disable:max-func-body-length no-any

import { expect } from 'chai';
import * as TypeMoq from 'typemoq';
import { IFileSystem } from '../../client/common/platform/types';
import { IProcessService } from '../../client/common/process/types';
import { IProcessService, IProcessServiceFactory } from '../../client/common/process/types';
import { IConfigurationService, IPersistentState, IPersistentStateFactory, IPythonSettings } from '../../client/common/types';
import { IInterpreterVersionService, InterpreterType, PythonInterpreter } from '../../client/interpreter/contracts';
import { CurrentPathService } from '../../client/interpreter/locators/services/currentPathService';
import { IVirtualEnvironmentManager } from '../../client/interpreter/virtualEnvs/types';
import { IServiceContainer } from '../../client/ioc/types';

// tslint:disable-next-line:max-func-body-length
suite('Interpreters CurrentPath Service', () => {
let processService: TypeMoq.IMock<IProcessService>;
let fileSystem: TypeMoq.IMock<IFileSystem>;
Expand All @@ -32,21 +33,22 @@ suite('Interpreters CurrentPath Service', () => {
configurationService.setup(c => c.getSettings(TypeMoq.It.isAny())).returns(() => pythonSettings.object);
const persistentStateFactory = TypeMoq.Mock.ofType<IPersistentStateFactory>();
persistentState = TypeMoq.Mock.ofType<IPersistentState<PythonInterpreter[]>>();
// tslint:disable-next-line:no-any
processService.setup((x: any) => x.then).returns(() => undefined);
persistentState.setup(p => p.value).returns(() => undefined as any);
persistentState.setup(p => p.updateValue(TypeMoq.It.isAny())).returns(() => Promise.resolve());
fileSystem = TypeMoq.Mock.ofType<IFileSystem>();
persistentStateFactory.setup(p => p.createGlobalPersistentState(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => persistentState.object);
const procServiceFactory = TypeMoq.Mock.ofType<IProcessServiceFactory>();
procServiceFactory.setup(p => p.create(TypeMoq.It.isAny())).returns(() => Promise.resolve(processService.object));

serviceContainer = TypeMoq.Mock.ofType<IServiceContainer>();
serviceContainer.setup(c => c.get(TypeMoq.It.isValue(IProcessService), TypeMoq.It.isAny())).returns(() => processService.object);
serviceContainer.setup(c => c.get(TypeMoq.It.isValue(IVirtualEnvironmentManager), TypeMoq.It.isAny())).returns(() => virtualEnvironmentManager.object);
serviceContainer.setup(c => c.get(TypeMoq.It.isValue(IInterpreterVersionService), TypeMoq.It.isAny())).returns(() => interpreterVersionService.object);
serviceContainer.setup(c => c.get(TypeMoq.It.isValue(IFileSystem), TypeMoq.It.isAny())).returns(() => fileSystem.object);
serviceContainer.setup(c => c.get(TypeMoq.It.isValue(IPersistentStateFactory), TypeMoq.It.isAny())).returns(() => persistentStateFactory.object);
serviceContainer.setup(c => c.get(TypeMoq.It.isValue(IConfigurationService), TypeMoq.It.isAny())).returns(() => configurationService.object);

currentPathService = new CurrentPathService(virtualEnvironmentManager.object, interpreterVersionService.object, processService.object, serviceContainer.object);
currentPathService = new CurrentPathService(virtualEnvironmentManager.object, interpreterVersionService.object, procServiceFactory.object, serviceContainer.object);
});

test('Interpreters that do not exist on the file system are not excluded from the list', async () => {
Expand Down
1 change: 1 addition & 0 deletions src/test/interpreters/pipEnvService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ suite('Interpreters - PipEnv', () => {
persistentStateFactory = TypeMoq.Mock.ofType<IPersistentStateFactory>();
envVarsProvider = TypeMoq.Mock.ofType<IEnvironmentVariablesProvider>();
procServiceFactory = TypeMoq.Mock.ofType<IProcessServiceFactory>();
processService.setup((x: any) => x.then).returns(() => undefined);
procServiceFactory.setup(p => p.create(TypeMoq.It.isAny())).returns(() => Promise.resolve(processService.object));

// tslint:disable-next-line:no-any
Expand Down
4 changes: 3 additions & 1 deletion src/test/interpreters/virtualEnvManager.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

// tslint:disable:no-any

import { expect } from 'chai';
import { Container } from 'inversify';
import * as TypeMoq from 'typemoq';
Expand Down Expand Up @@ -28,7 +30,6 @@ suite('Virtual environment manager', () => {

test('Run actual virtual env detection code', async () => {
const processServiceFactory = TypeMoq.Mock.ofType<IProcessServiceFactory>();
// tslint:disable-next-line:no-any
processServiceFactory.setup(f => f.create(TypeMoq.It.isAny())).returns(() => Promise.resolve(new ProcessService(new BufferDecoder(), process.env as any)));
serviceManager.addSingletonInstance<IProcessServiceFactory>(IProcessServiceFactory, processServiceFactory.object);
serviceManager.addSingleton<IBufferDecoder>(IBufferDecoder, BufferDecoder);
Expand All @@ -41,6 +42,7 @@ suite('Virtual environment manager', () => {
async function testSuffix(expectedName: string) {
const processService = TypeMoq.Mock.ofType<IProcessService>();
const processServiceFactory = TypeMoq.Mock.ofType<IProcessServiceFactory>();
processService.setup((x: any) => x.then).returns(() => undefined);
processServiceFactory.setup(f => f.create(TypeMoq.It.isAny())).returns(() => Promise.resolve(processService.object));
serviceManager.addSingletonInstance<IProcessServiceFactory>(IProcessServiceFactory, processServiceFactory.object);

Expand Down
5 changes: 2 additions & 3 deletions src/test/terminals/codeExecution/helper.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

// tslint:disable:no-multiline-string no-trailing-whitespace
// tslint:disable:no-multiline-string no-trailing-whitespace max-func-body-length no-any

import { expect } from 'chai';
import * as fs from 'fs-extra';
Expand All @@ -24,7 +24,6 @@ import { PYTHON_PATH } from '../../common';

const TEST_FILES_PATH = path.join(EXTENSION_ROOT_DIR, 'src', 'test', 'pythonFiles', 'terminalExec');

// tslint:disable-next-line:max-func-body-length
suite('Terminal - Code Execution Helper', () => {
let documentManager: TypeMoq.IMock<IDocumentManager>;
let applicationShell: TypeMoq.IMock<IApplicationShell>;
Expand All @@ -42,12 +41,12 @@ suite('Terminal - Code Execution Helper', () => {
configService = TypeMoq.Mock.ofType<IConfigurationService>();
const pythonSettings = TypeMoq.Mock.ofType<IPythonSettings>();
pythonSettings.setup(p => p.pythonPath).returns(() => PYTHON_PATH);
processService.setup((x: any) => x.then).returns(() => undefined);
configService.setup(c => c.getSettings(TypeMoq.It.isAny())).returns(() => pythonSettings.object);
envVariablesProvider.setup(e => e.getEnvironmentVariables(TypeMoq.It.isAny())).returns(() => Promise.resolve({}));
serviceContainer.setup(c => c.get(TypeMoq.It.isValue(IDocumentManager), TypeMoq.It.isAny())).returns(() => documentManager.object);
serviceContainer.setup(c => c.get(TypeMoq.It.isValue(IApplicationShell), TypeMoq.It.isAny())).returns(() => applicationShell.object);
serviceContainer.setup(c => c.get(TypeMoq.It.isValue(IEnvironmentVariablesProvider), TypeMoq.It.isAny())).returns(() => envVariablesProvider.object);
serviceContainer.setup(c => c.get(TypeMoq.It.isValue(IProcessService), TypeMoq.It.isAny())).returns(() => processService.object);
serviceContainer.setup(c => c.get(TypeMoq.It.isValue(IConfigurationService), TypeMoq.It.isAny())).returns(() => configService.object);
helper = new CodeExecutionHelper(serviceContainer.object);

Expand Down