@@ -26,12 +26,13 @@ import { sleep } from './core';
26
26
import { PythonEnvKind , PythonEnvSource } from '../client/pythonEnvironments/base/info' ;
27
27
import { Architecture } from '../client/common/utils/platform' ;
28
28
import { PythonEnvCollectionChangedEvent } from '../client/pythonEnvironments/base/watcher' ;
29
+ import { normCasePath } from '../client/common/platform/fs-paths' ;
29
30
import {
30
- ProposedExtensionAPI ,
31
- ActiveEnvironmentIdChangeEvent ,
31
+ ActiveEnvironmentPathChangeEvent ,
32
+ EnvironmentPath ,
32
33
EnvironmentsChangeEvent ,
34
+ ProposedExtensionAPI ,
33
35
} from '../client/proposedApiTypes' ;
34
- import { normCasePath } from '../client/common/platform/fs-paths' ;
35
36
36
37
suite ( 'Proposed Extension API' , ( ) => {
37
38
let serviceContainer : typemoq . IMock < IServiceContainer > ;
@@ -74,8 +75,8 @@ suite('Proposed Extension API', () => {
74
75
} ) ;
75
76
76
77
test ( 'Provide an event to track when active environment details change' , async ( ) => {
77
- const events : ActiveEnvironmentIdChangeEvent [ ] = [ ] ;
78
- proposed . environment . onDidChangeActiveEnvironmentId ( ( e ) => {
78
+ const events : ActiveEnvironmentPathChangeEvent [ ] = [ ] ;
79
+ proposed . environment . onDidChangeActiveEnvironmentPath ( ( e ) => {
79
80
events . push ( e ) ;
80
81
} ) ;
81
82
reportActiveInterpreterChanged ( { path : 'path/to/environment' , resource : undefined } ) ;
@@ -85,32 +86,44 @@ suite('Proposed Extension API', () => {
85
86
] ) ;
86
87
} ) ;
87
88
88
- test ( 'getActiveEnvironmentId : No resource' , ( ) => {
89
+ test ( 'getActiveEnvironmentPath : No resource' , ( ) => {
89
90
const pythonPath = 'this/is/a/test/path' ;
90
91
configService
91
92
. setup ( ( c ) => c . getSettings ( undefined ) )
92
93
. returns ( ( ) => ( ( { pythonPath } as unknown ) as IPythonSettings ) ) ;
93
- const actual = proposed . environment . getActiveEnvironmentId ( ) ;
94
- assert . deepEqual ( actual , { id : normCasePath ( pythonPath ) , path : pythonPath } ) ;
94
+ const actual = proposed . environment . getActiveEnvironmentPath ( ) ;
95
+ assert . deepEqual ( actual , ( {
96
+ id : normCasePath ( pythonPath ) ,
97
+ path : pythonPath ,
98
+ pathType : 'interpreterPath' ,
99
+ } as unknown ) as EnvironmentPath ) ;
95
100
} ) ;
96
101
97
- test ( 'getActiveEnvironmentId : default python' , ( ) => {
102
+ test ( 'getActiveEnvironmentPath : default python' , ( ) => {
98
103
const pythonPath = 'python' ;
99
104
configService
100
105
. setup ( ( c ) => c . getSettings ( undefined ) )
101
106
. returns ( ( ) => ( ( { pythonPath } as unknown ) as IPythonSettings ) ) ;
102
- const actual = proposed . environment . getActiveEnvironmentId ( ) ;
103
- assert . deepEqual ( actual , { id : 'DEFAULT_PYTHON' , path : pythonPath } ) ;
107
+ const actual = proposed . environment . getActiveEnvironmentPath ( ) ;
108
+ assert . deepEqual ( actual , ( {
109
+ id : 'DEFAULT_PYTHON' ,
110
+ path : pythonPath ,
111
+ pathType : 'interpreterPath' ,
112
+ } as unknown ) as EnvironmentPath ) ;
104
113
} ) ;
105
114
106
- test ( 'getActiveEnvironmentId : With resource' , ( ) => {
115
+ test ( 'getActiveEnvironmentPath : With resource' , ( ) => {
107
116
const pythonPath = 'this/is/a/test/path' ;
108
117
const resource = Uri . file ( __filename ) ;
109
118
configService
110
119
. setup ( ( c ) => c . getSettings ( resource ) )
111
120
. returns ( ( ) => ( ( { pythonPath } as unknown ) as IPythonSettings ) ) ;
112
- const actual = proposed . environment . getActiveEnvironmentId ( resource ) ;
113
- assert . deepEqual ( actual , { id : normCasePath ( pythonPath ) , path : pythonPath } ) ;
121
+ const actual = proposed . environment . getActiveEnvironmentPath ( resource ) ;
122
+ assert . deepEqual ( actual , ( {
123
+ id : normCasePath ( pythonPath ) ,
124
+ path : pythonPath ,
125
+ pathType : 'interpreterPath' ,
126
+ } as unknown ) as EnvironmentPath ) ;
114
127
} ) ;
115
128
116
129
test ( 'resolveEnvironment: invalid environment (when passed as string)' , async ( ) => {
@@ -317,44 +330,44 @@ suite('Proposed Extension API', () => {
317
330
assert . deepEqual ( eventValues , expectedEvents ) ;
318
331
} ) ;
319
332
320
- test ( 'updateActiveEnvironmentId : no resource' , async ( ) => {
333
+ test ( 'updateActiveEnvironmentPath : no resource' , async ( ) => {
321
334
interpreterPathService
322
335
. setup ( ( i ) => i . update ( undefined , ConfigurationTarget . WorkspaceFolder , 'this/is/a/test/python/path' ) )
323
336
. returns ( ( ) => Promise . resolve ( ) )
324
337
. verifiable ( typemoq . Times . once ( ) ) ;
325
338
326
- await proposed . environment . updateActiveEnvironmentId ( 'this/is/a/test/python/path' ) ;
339
+ await proposed . environment . updateActiveEnvironmentPath ( 'this/is/a/test/python/path' ) ;
327
340
328
341
interpreterPathService . verifyAll ( ) ;
329
342
} ) ;
330
343
331
- test ( 'updateActiveEnvironmentId : passed as Environment' , async ( ) => {
344
+ test ( 'updateActiveEnvironmentPath : passed as Environment' , async ( ) => {
332
345
interpreterPathService
333
346
. setup ( ( i ) => i . update ( undefined , ConfigurationTarget . WorkspaceFolder , 'this/is/a/test/python/path' ) )
334
347
. returns ( ( ) => Promise . resolve ( ) )
335
348
. verifiable ( typemoq . Times . once ( ) ) ;
336
349
337
- await proposed . environment . updateActiveEnvironmentId ( {
350
+ await proposed . environment . updateActiveEnvironmentPath ( {
338
351
id : normCasePath ( 'this/is/a/test/python/path' ) ,
339
352
path : 'this/is/a/test/python/path' ,
340
353
} ) ;
341
354
342
355
interpreterPathService . verifyAll ( ) ;
343
356
} ) ;
344
357
345
- test ( 'updateActiveEnvironmentId : with uri' , async ( ) => {
358
+ test ( 'updateActiveEnvironmentPath : with uri' , async ( ) => {
346
359
const uri = Uri . parse ( 'a' ) ;
347
360
interpreterPathService
348
361
. setup ( ( i ) => i . update ( uri , ConfigurationTarget . WorkspaceFolder , 'this/is/a/test/python/path' ) )
349
362
. returns ( ( ) => Promise . resolve ( ) )
350
363
. verifiable ( typemoq . Times . once ( ) ) ;
351
364
352
- await proposed . environment . updateActiveEnvironmentId ( 'this/is/a/test/python/path' , uri ) ;
365
+ await proposed . environment . updateActiveEnvironmentPath ( 'this/is/a/test/python/path' , uri ) ;
353
366
354
367
interpreterPathService . verifyAll ( ) ;
355
368
} ) ;
356
369
357
- test ( 'updateActiveEnvironmentId : with workspace folder' , async ( ) => {
370
+ test ( 'updateActiveEnvironmentPath : with workspace folder' , async ( ) => {
358
371
const uri = Uri . parse ( 'a' ) ;
359
372
interpreterPathService
360
373
. setup ( ( i ) => i . update ( uri , ConfigurationTarget . WorkspaceFolder , 'this/is/a/test/python/path' ) )
@@ -366,7 +379,7 @@ suite('Proposed Extension API', () => {
366
379
index : 0 ,
367
380
} ;
368
381
369
- await proposed . environment . updateActiveEnvironmentId ( 'this/is/a/test/python/path' , workspace ) ;
382
+ await proposed . environment . updateActiveEnvironmentPath ( 'this/is/a/test/python/path' , workspace ) ;
370
383
371
384
interpreterPathService . verifyAll ( ) ;
372
385
} ) ;
0 commit comments