@@ -12,9 +12,7 @@ import { IApplicationShell } from '../../client/common/application/types';
12
12
import { IPythonSettings } from '../../client/common/configSettings' ;
13
13
import { STANDARD_OUTPUT_CHANNEL } from '../../client/common/constants' ;
14
14
import { PythonInstaller } from '../../client/common/installer/pythonInstallation' ;
15
- import { IFileSystem , IPlatformService } from '../../client/common/platform/types' ;
16
- import { IProcessService , ObservableExecutionResult , Output } from '../../client/common/process/types' ;
17
- import { IOutputChannel } from '../../client/common/types' ;
15
+ import { IPlatformService } from '../../client/common/platform/types' ;
18
16
import { IInterpreterLocatorService } from '../../client/interpreter/contracts' ;
19
17
import { InterpreterType , PythonInterpreter } from '../../client/interpreter/contracts' ;
20
18
import { ServiceContainer } from '../../client/ioc/container' ;
@@ -26,12 +24,9 @@ class TestContext {
26
24
public serviceManager : ServiceManager ;
27
25
public serviceContainer : IServiceContainer ;
28
26
public platform : TypeMoq . IMock < IPlatformService > ;
29
- public fileSystem : TypeMoq . IMock < IFileSystem > ;
30
27
public appShell : TypeMoq . IMock < IApplicationShell > ;
31
28
public locator : TypeMoq . IMock < IInterpreterLocatorService > ;
32
29
public settings : TypeMoq . IMock < IPythonSettings > ;
33
- public process : TypeMoq . IMock < IProcessService > ;
34
- public output : TypeMoq . IMock < vscode . OutputChannel > ;
35
30
public pythonInstaller : PythonInstaller ;
36
31
37
32
constructor ( isMac : boolean ) {
@@ -40,19 +35,13 @@ class TestContext {
40
35
this . serviceContainer = new ServiceContainer ( cont ) ;
41
36
42
37
this . platform = TypeMoq . Mock . ofType < IPlatformService > ( ) ;
43
- this . fileSystem = TypeMoq . Mock . ofType < IFileSystem > ( ) ;
44
38
this . appShell = TypeMoq . Mock . ofType < IApplicationShell > ( ) ;
45
39
this . locator = TypeMoq . Mock . ofType < IInterpreterLocatorService > ( ) ;
46
40
this . settings = TypeMoq . Mock . ofType < IPythonSettings > ( ) ;
47
- this . process = TypeMoq . Mock . ofType < IProcessService > ( ) ;
48
- this . output = TypeMoq . Mock . ofType < vscode . OutputChannel > ( ) ;
49
41
50
42
this . serviceManager . addSingletonInstance < IPlatformService > ( IPlatformService , this . platform . object ) ;
51
- this . serviceManager . addSingletonInstance < IFileSystem > ( IFileSystem , this . fileSystem . object ) ;
52
43
this . serviceManager . addSingletonInstance < IApplicationShell > ( IApplicationShell , this . appShell . object ) ;
53
44
this . serviceManager . addSingletonInstance < IInterpreterLocatorService > ( IInterpreterLocatorService , this . locator . object ) ;
54
- this . serviceManager . addSingletonInstance < IProcessService > ( IProcessService , this . process . object ) ;
55
- this . serviceManager . addSingletonInstance < vscode . OutputChannel > ( IOutputChannel , this . output . object , STANDARD_OUTPUT_CHANNEL ) ;
56
45
this . pythonInstaller = new PythonInstaller ( this . serviceContainer ) ;
57
46
58
47
this . platform . setup ( x => x . isMac ) . returns ( ( ) => isMac ) ;
@@ -80,7 +69,7 @@ suite('Installation', () => {
80
69
assert . equal ( showErrorMessageCalled , false , 'Disabling checks has no effect' ) ;
81
70
} ) ;
82
71
83
- test ( 'Windows: Python missing' , async ( ) => {
72
+ test ( 'Python missing' , async ( ) => {
84
73
const c = new TestContext ( false ) ;
85
74
let showErrorMessageCalled = false ;
86
75
let openUrlCalled = false ;
@@ -100,7 +89,7 @@ suite('Installation', () => {
100
89
assert . equal ( url , 'https://www.python.org/downloads' , 'Python download page is incorrect' ) ;
101
90
} ) ;
102
91
103
- test ( 'Mac: Python missing ' , async ( ) => {
92
+ test ( 'Mac: Default Python warning ' , async ( ) => {
104
93
const c = new TestContext ( true ) ;
105
94
let called = false ;
106
95
c . appShell . setup ( x => x . showWarningMessage ( TypeMoq . It . isAnyString ( ) ) ) . callback ( ( ) => called = true ) ;
@@ -115,89 +104,4 @@ suite('Installation', () => {
115
104
assert . equal ( passed , true , 'Default MacOS Python not accepted' ) ;
116
105
assert . equal ( called , true , 'Warning not shown' ) ;
117
106
} ) ;
118
-
119
- test ( 'Mac: Default Python, user refused install' , async ( ) => {
120
- const c = new TestContext ( true ) ;
121
- let errorMessage = '' ;
122
-
123
- c . appShell
124
- . setup ( x => x . showErrorMessage ( TypeMoq . It . isAnyString ( ) , TypeMoq . It . isAnyString ( ) , TypeMoq . It . isAnyString ( ) ) )
125
- . callback ( ( m : string , a1 : string , a2 : string ) => errorMessage = m )
126
- . returns ( ( ) => Promise . resolve ( 'No' ) ) ;
127
- c . locator . setup ( x => x . getInterpreters ( ) ) . returns ( ( ) => Promise . resolve ( [ ] ) ) ;
128
-
129
- const passed = await c . pythonInstaller . checkPythonInstallation ( c . settings . object ) ;
130
- assert . equal ( passed , false , 'Default MacOS Python accepted' ) ;
131
- assert . equal ( errorMessage . startsWith ( 'Python that comes with MacOS is not supported' ) , true , 'Error message that MacOS Python not supported not shown' ) ;
132
- } ) ;
133
-
134
- test ( 'Mac: Default Python, Brew installation' , async ( ) => {
135
- const c = new TestContext ( true ) ;
136
- let errorMessage = '' ;
137
- let processName = '' ;
138
- let args ;
139
- let brewPath ;
140
- let outputShown = false ;
141
-
142
- c . appShell
143
- . setup ( x => x . showErrorMessage ( TypeMoq . It . isAnyString ( ) , TypeMoq . It . isAnyString ( ) , TypeMoq . It . isAnyString ( ) ) )
144
- . returns ( ( ) => Promise . resolve ( 'Yes' ) ) ;
145
- c . appShell
146
- . setup ( x => x . showErrorMessage ( TypeMoq . It . isAnyString ( ) ) )
147
- . callback ( ( m : string ) => errorMessage = m ) ;
148
- c . locator . setup ( x => x . getInterpreters ( ) ) . returns ( ( ) => Promise . resolve ( [ ] ) ) ;
149
- c . fileSystem
150
- . setup ( x => x . fileExistsAsync ( TypeMoq . It . isAnyString ( ) ) )
151
- . returns ( ( p : string ) => {
152
- brewPath = p ;
153
- return Promise . resolve ( false ) ;
154
- } ) ;
155
-
156
- const childProcess = TypeMoq . Mock . ofType < ChildProcess > ( ) ;
157
- childProcess
158
- . setup ( p => p . on ( 'exit' , TypeMoq . It . isAny ( ) ) )
159
- . callback ( ( e : string , listener : ( code , signal ) => void ) => {
160
- listener . call ( 0 , undefined ) ;
161
- } ) ;
162
- const processOutput : Output < string > = {
163
- source : 'stdout' ,
164
- out : 'started'
165
- } ;
166
- const observable = new Rx . Observable < Output < string > > ( subscriber => subscriber . next ( processOutput ) ) ;
167
- const brewInstallProcess : ObservableExecutionResult < string > = {
168
- proc : childProcess . object ,
169
- out : observable
170
- } ;
171
-
172
- c . output . setup ( x => x . show ( ) ) . callback ( ( ) => outputShown = true ) ;
173
- c . process
174
- . setup ( x => x . execObservable ( TypeMoq . It . isAnyString ( ) , TypeMoq . It . isAny ( ) , TypeMoq . It . isAny ( ) ) )
175
- . callback ( ( p : string , a : string [ ] , o : SpawnOptions ) => {
176
- processName = p ;
177
- args = a ;
178
- } )
179
- . returns ( ( ) => brewInstallProcess ) ;
180
-
181
- await c . pythonInstaller . checkPythonInstallation ( c . settings . object ) ;
182
-
183
- assert . notEqual ( brewPath , undefined , 'Brew installer location not checked' ) ;
184
- assert . equal ( brewPath , '/usr/local/bin/brew' , 'Brew installer location is incorrect' ) ;
185
- assert . notEqual ( processName , undefined , 'Brew installer not invoked' ) ;
186
- assert . equal ( processName , '/usr/bin/ruby' , 'Brew installer name is incorrect' ) ;
187
- assert . equal ( args [ 0 ] , '-e' , 'Brew installer argument is incorrect' ) ;
188
- assert . equal ( args [ 1 ] , '"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"' , 'Homebrew installer argument is incorrect' ) ;
189
- assert . equal ( outputShown , true , 'Output panel not shown' ) ;
190
- assert . equal ( errorMessage . startsWith ( 'Unable to install Homebrew' ) , true , 'Homebrew install failed message no shown' ) ;
191
-
192
- c . fileSystem
193
- . setup ( x => x . fileExistsAsync ( TypeMoq . It . isAnyString ( ) ) )
194
- . returns ( ( ) => Promise . resolve ( true ) ) ;
195
- errorMessage = '' ;
196
-
197
- await c . pythonInstaller . checkPythonInstallation ( c . settings . object ) ;
198
- assert . equal ( errorMessage , '' , `Unexpected error message ${ errorMessage } ` ) ;
199
- assert . equal ( processName , 'brew' , 'Brew installer name is incorrect' ) ;
200
- assert . equal ( args [ 0 ] , 'install' , 'Brew "install" argument is incorrect' ) ;
201
- assert . equal ( args [ 1 ] , 'python' , 'Brew "python" argument is incorrect' ) ;
202
- } ) ;
203
107
} ) ;
0 commit comments