55
66import { expect } from 'chai' ;
77import * as TypeMoq from 'typemoq' ;
8- import { Uri , WorkspaceConfiguration } from 'vscode' ;
8+ import { Uri } from 'vscode' ;
99import { IWorkspaceService } from '../client/common/application/types' ;
1010import { DeprecatePythonPath } from '../client/common/experiments/groups' ;
1111import { IExperimentService , IInterpreterPathService } from '../client/common/types' ;
@@ -28,26 +28,12 @@ suite('Startup Telemetry - hasUserDefinedPythonPath()', async () => {
2828 serviceContainer . setup ( ( s ) => s . get ( IInterpreterPathService ) ) . returns ( ( ) => interpreterPathService . object ) ;
2929 } ) ;
3030
31- function setupConfigProvider ( ) : TypeMoq . IMock < WorkspaceConfiguration > {
32- const workspaceConfig = TypeMoq . Mock . ofType < WorkspaceConfiguration > ( ) ;
33- workspaceService
34- . setup ( ( w ) => w . getConfiguration ( TypeMoq . It . isValue ( 'python' ) , TypeMoq . It . isValue ( resource ) ) )
35- . returns ( ( ) => workspaceConfig . object ) ;
36- return workspaceConfig ;
37- }
38-
3931 [ undefined , 'python' ] . forEach ( ( globalValue ) => {
4032 [ undefined , 'python' ] . forEach ( ( workspaceValue ) => {
4133 [ undefined , 'python' ] . forEach ( ( workspaceFolderValue ) => {
4234 test ( `Return false if using settings equals {globalValue: ${ globalValue } , workspaceValue: ${ workspaceValue } , workspaceFolderValue: ${ workspaceFolderValue } }` , ( ) => {
43- experimentsManager
44- . setup ( ( e ) => e . inExperimentSync ( DeprecatePythonPath . experiment ) )
45- . returns ( ( ) => false ) ;
46- const workspaceConfig = setupConfigProvider ( ) ;
47-
48- workspaceConfig
49- . setup ( ( w ) => w . inspect ( 'pythonPath' ) )
50-
35+ interpreterPathService
36+ . setup ( ( i ) => i . inspect ( resource ) )
5137 . returns ( ( ) => ( { globalValue, workspaceValue, workspaceFolderValue } as any ) ) ;
5238 const result = hasUserDefinedPythonPath ( resource , serviceContainer . object ) ;
5339 expect ( result ) . to . equal ( false , 'Should be false' ) ;
@@ -58,19 +44,16 @@ suite('Startup Telemetry - hasUserDefinedPythonPath()', async () => {
5844
5945 test ( 'Return true if using setting value equals something else' , ( ) => {
6046 experimentsManager . setup ( ( e ) => e . inExperimentSync ( DeprecatePythonPath . experiment ) ) . returns ( ( ) => false ) ;
61- const workspaceConfig = setupConfigProvider ( ) ;
62-
63- workspaceConfig . setup ( ( w ) => w . inspect ( 'pythonPath' ) ) . returns ( ( ) => ( { globalValue : 'something else' } as any ) ) ;
47+ interpreterPathService
48+ . setup ( ( i ) => i . inspect ( resource ) )
49+ . returns ( ( ) => ( { globalValue : 'something else' } as any ) ) ;
6450 const result = hasUserDefinedPythonPath ( resource , serviceContainer . object ) ;
6551 expect ( result ) . to . equal ( true , 'Should be true' ) ;
6652 } ) ;
6753
6854 test ( 'If in Deprecate PythonPath experiment, use the new API to inspect settings' , ( ) => {
6955 experimentsManager . setup ( ( e ) => e . inExperimentSync ( DeprecatePythonPath . experiment ) ) . returns ( ( ) => true ) ;
70- interpreterPathService
71- . setup ( ( i ) => i . inspect ( resource ) )
72- . returns ( ( ) => ( { } ) )
73- . verifiable ( TypeMoq . Times . once ( ) ) ;
56+ interpreterPathService . setup ( ( i ) => i . inspect ( resource ) ) . returns ( ( ) => ( { } ) ) ;
7457 hasUserDefinedPythonPath ( resource , serviceContainer . object ) ;
7558 interpreterPathService . verifyAll ( ) ;
7659 } ) ;
0 commit comments