5
5
6
6
import { expect } from 'chai' ;
7
7
import * as TypeMoq from 'typemoq' ;
8
- import { Uri , WorkspaceConfiguration } from 'vscode' ;
8
+ import { Uri } from 'vscode' ;
9
9
import { IWorkspaceService } from '../client/common/application/types' ;
10
10
import { DeprecatePythonPath } from '../client/common/experiments/groups' ;
11
11
import { IExperimentService , IInterpreterPathService } from '../client/common/types' ;
@@ -28,26 +28,12 @@ suite('Startup Telemetry - hasUserDefinedPythonPath()', async () => {
28
28
serviceContainer . setup ( ( s ) => s . get ( IInterpreterPathService ) ) . returns ( ( ) => interpreterPathService . object ) ;
29
29
} ) ;
30
30
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
-
39
31
[ undefined , 'python' ] . forEach ( ( globalValue ) => {
40
32
[ undefined , 'python' ] . forEach ( ( workspaceValue ) => {
41
33
[ undefined , 'python' ] . forEach ( ( workspaceFolderValue ) => {
42
34
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 ) )
51
37
. returns ( ( ) => ( { globalValue, workspaceValue, workspaceFolderValue } as any ) ) ;
52
38
const result = hasUserDefinedPythonPath ( resource , serviceContainer . object ) ;
53
39
expect ( result ) . to . equal ( false , 'Should be false' ) ;
@@ -58,19 +44,16 @@ suite('Startup Telemetry - hasUserDefinedPythonPath()', async () => {
58
44
59
45
test ( 'Return true if using setting value equals something else' , ( ) => {
60
46
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 ) ) ;
64
50
const result = hasUserDefinedPythonPath ( resource , serviceContainer . object ) ;
65
51
expect ( result ) . to . equal ( true , 'Should be true' ) ;
66
52
} ) ;
67
53
68
54
test ( 'If in Deprecate PythonPath experiment, use the new API to inspect settings' , ( ) => {
69
55
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 ( ( ) => ( { } ) ) ;
74
57
hasUserDefinedPythonPath ( resource , serviceContainer . object ) ;
75
58
interpreterPathService . verifyAll ( ) ;
76
59
} ) ;
0 commit comments