Skip to content

Commit 9ef3352

Browse files
author
Kartik Raj
committed
Fix unit tests
1 parent eccdc78 commit 9ef3352

File tree

5 files changed

+22
-32
lines changed

5 files changed

+22
-32
lines changed

src/test/application/diagnostics/checks/macPythonInterpreter.unit.test.ts

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ suite('Application Diagnostics - Checks Mac Python Interpreter', () => {
169169
.returns(() => false)
170170
.verifiable(typemoq.Times.once());
171171
interpreterService
172-
.setup((i) => i.hasInterpreters)
172+
.setup((i) => i.hasInterpreters())
173173
.returns(() => Promise.resolve(true))
174174
.verifiable(typemoq.Times.once());
175175
interpreterService
@@ -199,7 +199,7 @@ suite('Application Diagnostics - Checks Mac Python Interpreter', () => {
199199
.returns(() => false)
200200
.verifiable(typemoq.Times.once());
201201
interpreterService
202-
.setup((i) => i.hasInterpreters)
202+
.setup((i) => i.hasInterpreters())
203203
.returns(() => Promise.resolve(true))
204204
.verifiable(typemoq.Times.once());
205205
interpreterService
@@ -234,8 +234,12 @@ suite('Application Diagnostics - Checks Mac Python Interpreter', () => {
234234
.returns(() => false)
235235
.verifiable(typemoq.Times.once());
236236
interpreterService
237-
.setup((i) => i.getInterpreters(typemoq.It.isAny()))
238-
.returns(() => Promise.resolve([{ path: pythonPath } as any, { path: pythonPath } as any]))
237+
.setup((i) => i.hasInterpreters())
238+
.returns(() => Promise.resolve(true))
239+
.verifiable(typemoq.Times.once());
240+
interpreterService
241+
.setup((i) => i.hasInterpreters(typemoq.It.isAny()))
242+
.returns(() => Promise.resolve(false))
239243
.verifiable(typemoq.Times.once());
240244
interpreterService
241245
.setup((i) => i.getActiveInterpreter(typemoq.It.isAny()))
@@ -262,10 +266,6 @@ suite('Application Diagnostics - Checks Mac Python Interpreter', () => {
262266
],
263267
'not the same',
264268
);
265-
settings.verifyAll();
266-
interpreterService.verifyAll();
267-
platformService.verifyAll();
268-
helper.verifyAll();
269269
});
270270
test('Should return diagnostic if there are other interpreters, platform is mac and selected interpreter is default mac interpreter', async () => {
271271
const nonMacStandardInterpreter = 'Non Mac Std Interpreter';
@@ -274,14 +274,12 @@ suite('Application Diagnostics - Checks Mac Python Interpreter', () => {
274274
.returns(() => false)
275275
.verifiable(typemoq.Times.once());
276276
interpreterService
277-
.setup((i) => i.getInterpreters(typemoq.It.isAny()))
278-
.returns(() =>
279-
Promise.resolve([
280-
{ path: pythonPath } as any,
281-
{ path: pythonPath } as any,
282-
{ path: nonMacStandardInterpreter } as any,
283-
]),
284-
)
277+
.setup((i) => i.hasInterpreters())
278+
.returns(() => Promise.resolve(true))
279+
.verifiable(typemoq.Times.once());
280+
interpreterService
281+
.setup((i) => i.hasInterpreters(typemoq.It.isAny()))
282+
.returns(() => Promise.resolve(true))
285283
.verifiable(typemoq.Times.once());
286284
platformService
287285
.setup((i) => i.isMac)
@@ -312,10 +310,6 @@ suite('Application Diagnostics - Checks Mac Python Interpreter', () => {
312310
],
313311
'not the same',
314312
);
315-
settings.verifyAll();
316-
interpreterService.verifyAll();
317-
platformService.verifyAll();
318-
helper.verifyAll();
319313
});
320314
test('Handling no interpreters diagnostic should return select interpreter cmd', async () => {
321315
const diagnostic = new InvalidMacPythonInterpreterDiagnostic(

src/test/application/diagnostics/checks/pythonInterpreter.unit.test.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ suite('Application Diagnostics - Checks Python Interpreter', () => {
134134
.returns(() => false)
135135
.verifiable(typemoq.Times.once());
136136
interpreterService
137-
.setup((i) => i.hasInterpreters)
137+
.setup((i) => i.hasInterpreters())
138138
.returns(() => Promise.resolve(false))
139139
.verifiable(typemoq.Times.once());
140140
interpreterService
@@ -147,8 +147,6 @@ suite('Application Diagnostics - Checks Python Interpreter', () => {
147147
[new InvalidPythonInterpreterDiagnostic(DiagnosticCodes.NoPythonInterpretersDiagnostic, undefined)],
148148
'not the same',
149149
);
150-
settings.verifyAll();
151-
interpreterService.verifyAll();
152150
});
153151
test('Should return empty diagnostics if there are interpreters after double-checking', async () => {
154152
const interpreter: PythonEnvironment = { envType: EnvironmentType.Unknown } as any;
@@ -158,7 +156,7 @@ suite('Application Diagnostics - Checks Python Interpreter', () => {
158156
.returns(() => false)
159157
.verifiable(typemoq.Times.once());
160158
interpreterService
161-
.setup((i) => i.hasInterpreters)
159+
.setup((i) => i.hasInterpreters())
162160
.returns(() => Promise.resolve(false))
163161
.verifiable(typemoq.Times.once());
164162
interpreterService
@@ -175,16 +173,14 @@ suite('Application Diagnostics - Checks Python Interpreter', () => {
175173
const diagnostics = await diagnosticService.diagnose(undefined);
176174

177175
expect(diagnostics).to.be.deep.equal([], 'not the same');
178-
settings.verifyAll();
179-
interpreterService.verifyAll();
180176
});
181177
test('Should return invalid diagnostics if there are interpreters but no current interpreter', async () => {
182178
settings
183179
.setup((s) => s.disableInstallationChecks)
184180
.returns(() => false)
185181
.verifiable(typemoq.Times.once());
186182
interpreterService
187-
.setup((i) => i.hasInterpreters)
183+
.setup((i) => i.hasInterpreters())
188184
.returns(() => Promise.resolve(true))
189185
.verifiable(typemoq.Times.once());
190186
interpreterService
@@ -213,7 +209,7 @@ suite('Application Diagnostics - Checks Python Interpreter', () => {
213209
.returns(() => false)
214210
.verifiable(typemoq.Times.once());
215211
interpreterService
216-
.setup((i) => i.hasInterpreters)
212+
.setup((i) => i.hasInterpreters())
217213
.returns(() => Promise.resolve(true))
218214
.verifiable(typemoq.Times.once());
219215
interpreterService

src/test/common/process/pythonExecutionFactory.unit.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ suite('Process - PythonExecutionFactory', () => {
285285
const pythonPath = 'path/to/python';
286286
const pythonSettings = mock(PythonSettings);
287287

288-
when(interpreterService.hasInterpreters).thenResolve(true);
288+
when(interpreterService.hasInterpreters()).thenResolve(true);
289289
when(processFactory.create(resource)).thenResolve(processService.object);
290290
when(pythonSettings.pythonPath).thenReturn(pythonPath);
291291
when(configService.getSettings(resource)).thenReturn(instance(pythonSettings));
@@ -315,7 +315,7 @@ suite('Process - PythonExecutionFactory', () => {
315315
when(pythonSettings.pythonPath).thenReturn(pythonPath);
316316
when(configService.getSettings(resource)).thenReturn(instance(pythonSettings));
317317
when(condaService.getCondaVersion()).thenResolve(new SemVer('1.0.0'));
318-
when(interpreterService.hasInterpreters).thenResolve(true);
318+
when(interpreterService.hasInterpreters()).thenResolve(true);
319319

320320
const service = await factory.create({ resource });
321321

src/test/linters/lint.functional.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ class TestFixture extends BaseTestFixture {
697697
.returns(() => decoder);
698698

699699
const interpreterService = TypeMoq.Mock.ofType<IInterpreterService>(undefined, TypeMoq.MockBehavior.Strict);
700-
interpreterService.setup((i) => i.hasInterpreters).returns(() => Promise.resolve(true));
700+
interpreterService.setup((i) => i.hasInterpreters()).returns(() => Promise.resolve(true));
701701
serviceContainer
702702
.setup((c) => c.get(TypeMoq.It.isValue(IInterpreterService), TypeMoq.It.isAny()))
703703
.returns(() => interpreterService.object);

src/test/refactor/rename.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ suite('Refactor Rename', () => {
6363
.setup((p) => p.create(typeMoq.It.isAny()))
6464
.returns(() => Promise.resolve(new ProcessService(new BufferDecoder())));
6565
const interpreterService = typeMoq.Mock.ofType<IInterpreterService>();
66-
interpreterService.setup((i) => i.hasInterpreters).returns(() => Promise.resolve(true));
66+
interpreterService.setup((i) => i.hasInterpreters()).returns(() => Promise.resolve(true));
6767
const envActivationService = typeMoq.Mock.ofType<IEnvironmentActivationService>();
6868
envActivationService
6969
.setup((e) => e.getActivatedEnvironmentVariables(typeMoq.It.isAny()))

0 commit comments

Comments
 (0)