11import assert from 'assert' ;
22import * as sinon from 'sinon' ;
3- import { CancellationToken , LogOutputChannel , Progress , Uri } from 'vscode' ;
4- import { EnvironmentManager , PythonEnvironment } from '../../../api' ;
3+ import { CancellationToken , LogOutputChannel , Progress , ProgressLocation , Uri } from 'vscode' ;
4+ import { EnvironmentManager , PythonEnvironment , PythonEnvironmentApi } from '../../../api' ;
55import * as winapi from '../../../common/window.apis' ;
66import { createWithProgress } from '../../../managers/builtin/venvUtils' ;
77
88suite ( 'Venv Progress Merge Tests' , ( ) => {
99 let mockWithProgress : sinon . SinonStub ;
1010 let mockManagePackages : sinon . SinonStub ;
11- let mockNativeFinder : any ;
12- let mockApi : any ;
13- let mockLog : any ;
14- let mockManager : any ;
11+ let mockNativeFinder : {
12+ resolve : sinon . SinonStub ;
13+ refresh : sinon . SinonStub ;
14+ dispose : sinon . SinonStub ;
15+ } ;
16+ // Minimal mock that only implements the methods we need for this test
17+ // Using type assertion to satisfy TypeScript since we only need createPythonEnvironmentItem and managePackages
18+ let mockApi : {
19+ createPythonEnvironmentItem : sinon . SinonStub ;
20+ managePackages : sinon . SinonStub ;
21+ } ;
22+ let mockLog : LogOutputChannel ;
23+ let mockManager : EnvironmentManager ;
1524 let mockBasePython : PythonEnvironment ;
1625 let progressReportStub : sinon . SinonStub ;
1726
1827 setup ( ( ) => {
1928 // Stub withProgress to capture the progress callback
2029 progressReportStub = sinon . stub ( ) ;
2130 mockWithProgress = sinon . stub ( winapi , 'withProgress' ) ;
22- mockWithProgress . callsFake ( async ( _options : any , callback : Function ) => {
23- const mockProgress : Progress < { message ?: string ; increment ?: number } > = {
24- report : progressReportStub ,
25- } ;
26- const mockToken : CancellationToken = {
27- isCancellationRequested : false ,
28- onCancellationRequested : sinon . stub ( ) ,
29- } ;
30- return await callback ( mockProgress , mockToken ) ;
31- } ) ;
31+ mockWithProgress . callsFake (
32+ async ( _options : { location : ProgressLocation ; title : string } , callback : Function ) => {
33+ const mockProgress : Progress < { message ?: string ; increment ?: number } > = {
34+ report : progressReportStub ,
35+ } ;
36+ const mockToken : CancellationToken = {
37+ isCancellationRequested : false ,
38+ onCancellationRequested : sinon . stub ( ) ,
39+ } ;
40+ return await callback ( mockProgress , mockToken ) ;
41+ } ,
42+ ) ;
3243
3344 // Create minimal mocks
3445 mockNativeFinder = {
@@ -38,6 +49,8 @@ suite('Venv Progress Merge Tests', () => {
3849 prefix : '/test/venv' ,
3950 kind : 'venv' ,
4051 } ) ,
52+ refresh : sinon . stub ( ) . resolves ( [ ] ) ,
53+ dispose : sinon . stub ( ) ,
4154 } ;
4255 mockApi = {
4356 createPythonEnvironmentItem : sinon . stub ( ) . returns ( {
@@ -81,10 +94,10 @@ suite('Venv Progress Merge Tests', () => {
8194 sinon . stub ( helpers , 'runPython' ) . resolves ( ) ;
8295
8396 await createWithProgress (
84- mockNativeFinder as any ,
85- mockApi as any ,
86- mockLog as any ,
87- mockManager as any ,
97+ mockNativeFinder ,
98+ mockApi as unknown as PythonEnvironmentApi ,
99+ mockLog ,
100+ mockManager ,
88101 mockBasePython ,
89102 Uri . file ( '/test' ) ,
90103 '/test/venv' ,
@@ -111,10 +124,10 @@ suite('Venv Progress Merge Tests', () => {
111124 sinon . stub ( helpers , 'runPython' ) . resolves ( ) ;
112125
113126 await createWithProgress (
114- mockNativeFinder as any ,
115- mockApi as any ,
116- mockLog as any ,
117- mockManager as any ,
127+ mockNativeFinder ,
128+ mockApi as unknown as PythonEnvironmentApi ,
129+ mockLog ,
130+ mockManager ,
118131 mockBasePython ,
119132 Uri . file ( '/test' ) ,
120133 '/test/venv' ,
@@ -142,10 +155,10 @@ suite('Venv Progress Merge Tests', () => {
142155 sinon . stub ( helpers , 'runPython' ) . resolves ( ) ;
143156
144157 await createWithProgress (
145- mockNativeFinder as any ,
146- mockApi as any ,
147- mockLog as any ,
148- mockManager as any ,
158+ mockNativeFinder ,
159+ mockApi as unknown as PythonEnvironmentApi ,
160+ mockLog ,
161+ mockManager ,
149162 mockBasePython ,
150163 Uri . file ( '/test' ) ,
151164 '/test/venv' ,
0 commit comments