@@ -26,12 +26,13 @@ import { sleep } from './core';
2626import { PythonEnvKind , PythonEnvSource } from '../client/pythonEnvironments/base/info' ;
2727import { Architecture } from '../client/common/utils/platform' ;
2828import { PythonEnvCollectionChangedEvent } from '../client/pythonEnvironments/base/watcher' ;
29+ import { normCasePath } from '../client/common/platform/fs-paths' ;
2930import {
30- ProposedExtensionAPI ,
31- ActiveEnvironmentIdChangeEvent ,
31+ ActiveEnvironmentPathChangeEvent ,
32+ EnvironmentPath ,
3233 EnvironmentsChangeEvent ,
34+ ProposedExtensionAPI ,
3335} from '../client/proposedApiTypes' ;
34- import { normCasePath } from '../client/common/platform/fs-paths' ;
3536
3637suite ( 'Proposed Extension API' , ( ) => {
3738 let serviceContainer : typemoq . IMock < IServiceContainer > ;
@@ -74,8 +75,8 @@ suite('Proposed Extension API', () => {
7475 } ) ;
7576
7677 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 ) => {
7980 events . push ( e ) ;
8081 } ) ;
8182 reportActiveInterpreterChanged ( { path : 'path/to/environment' , resource : undefined } ) ;
@@ -85,32 +86,44 @@ suite('Proposed Extension API', () => {
8586 ] ) ;
8687 } ) ;
8788
88- test ( 'getActiveEnvironmentId : No resource' , ( ) => {
89+ test ( 'getActiveEnvironmentPath : No resource' , ( ) => {
8990 const pythonPath = 'this/is/a/test/path' ;
9091 configService
9192 . setup ( ( c ) => c . getSettings ( undefined ) )
9293 . 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 ) ;
95100 } ) ;
96101
97- test ( 'getActiveEnvironmentId : default python' , ( ) => {
102+ test ( 'getActiveEnvironmentPath : default python' , ( ) => {
98103 const pythonPath = 'python' ;
99104 configService
100105 . setup ( ( c ) => c . getSettings ( undefined ) )
101106 . 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 ) ;
104113 } ) ;
105114
106- test ( 'getActiveEnvironmentId : With resource' , ( ) => {
115+ test ( 'getActiveEnvironmentPath : With resource' , ( ) => {
107116 const pythonPath = 'this/is/a/test/path' ;
108117 const resource = Uri . file ( __filename ) ;
109118 configService
110119 . setup ( ( c ) => c . getSettings ( resource ) )
111120 . 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 ) ;
114127 } ) ;
115128
116129 test ( 'resolveEnvironment: invalid environment (when passed as string)' , async ( ) => {
@@ -317,44 +330,44 @@ suite('Proposed Extension API', () => {
317330 assert . deepEqual ( eventValues , expectedEvents ) ;
318331 } ) ;
319332
320- test ( 'updateActiveEnvironmentId : no resource' , async ( ) => {
333+ test ( 'updateActiveEnvironmentPath : no resource' , async ( ) => {
321334 interpreterPathService
322335 . setup ( ( i ) => i . update ( undefined , ConfigurationTarget . WorkspaceFolder , 'this/is/a/test/python/path' ) )
323336 . returns ( ( ) => Promise . resolve ( ) )
324337 . verifiable ( typemoq . Times . once ( ) ) ;
325338
326- await proposed . environment . updateActiveEnvironmentId ( 'this/is/a/test/python/path' ) ;
339+ await proposed . environment . updateActiveEnvironmentPath ( 'this/is/a/test/python/path' ) ;
327340
328341 interpreterPathService . verifyAll ( ) ;
329342 } ) ;
330343
331- test ( 'updateActiveEnvironmentId : passed as Environment' , async ( ) => {
344+ test ( 'updateActiveEnvironmentPath : passed as Environment' , async ( ) => {
332345 interpreterPathService
333346 . setup ( ( i ) => i . update ( undefined , ConfigurationTarget . WorkspaceFolder , 'this/is/a/test/python/path' ) )
334347 . returns ( ( ) => Promise . resolve ( ) )
335348 . verifiable ( typemoq . Times . once ( ) ) ;
336349
337- await proposed . environment . updateActiveEnvironmentId ( {
350+ await proposed . environment . updateActiveEnvironmentPath ( {
338351 id : normCasePath ( 'this/is/a/test/python/path' ) ,
339352 path : 'this/is/a/test/python/path' ,
340353 } ) ;
341354
342355 interpreterPathService . verifyAll ( ) ;
343356 } ) ;
344357
345- test ( 'updateActiveEnvironmentId : with uri' , async ( ) => {
358+ test ( 'updateActiveEnvironmentPath : with uri' , async ( ) => {
346359 const uri = Uri . parse ( 'a' ) ;
347360 interpreterPathService
348361 . setup ( ( i ) => i . update ( uri , ConfigurationTarget . WorkspaceFolder , 'this/is/a/test/python/path' ) )
349362 . returns ( ( ) => Promise . resolve ( ) )
350363 . verifiable ( typemoq . Times . once ( ) ) ;
351364
352- await proposed . environment . updateActiveEnvironmentId ( 'this/is/a/test/python/path' , uri ) ;
365+ await proposed . environment . updateActiveEnvironmentPath ( 'this/is/a/test/python/path' , uri ) ;
353366
354367 interpreterPathService . verifyAll ( ) ;
355368 } ) ;
356369
357- test ( 'updateActiveEnvironmentId : with workspace folder' , async ( ) => {
370+ test ( 'updateActiveEnvironmentPath : with workspace folder' , async ( ) => {
358371 const uri = Uri . parse ( 'a' ) ;
359372 interpreterPathService
360373 . setup ( ( i ) => i . update ( uri , ConfigurationTarget . WorkspaceFolder , 'this/is/a/test/python/path' ) )
@@ -366,7 +379,7 @@ suite('Proposed Extension API', () => {
366379 index : 0 ,
367380 } ;
368381
369- await proposed . environment . updateActiveEnvironmentId ( 'this/is/a/test/python/path' , workspace ) ;
382+ await proposed . environment . updateActiveEnvironmentPath ( 'this/is/a/test/python/path' , workspace ) ;
370383
371384 interpreterPathService . verifyAll ( ) ;
372385 } ) ;
0 commit comments