4
4
'use strict' ;
5
5
6
6
import { assert } from 'chai' ;
7
- import { anything , deepEqual , instance , mock , verify , when } from 'ts-mockito' ;
7
+ import { anything , instance , mock , verify , when } from 'ts-mockito' ;
8
8
import { ApplicationShell } from '../../../../client/common/application/applicationShell' ;
9
9
import { IApplicationShell } from '../../../../client/common/application/types' ;
10
10
import { ProductInstaller } from '../../../../client/common/installer/productInstaller' ;
11
- import { PythonExecutionFactory } from '../../../../client/common/process/pythonExecutionFactory' ;
12
- import { PythonExecutionService } from '../../../../client/common/process/pythonProcess' ;
13
- import { IPythonExecutionService } from '../../../../client/common/process/types' ;
14
11
import { IInstaller , InstallerResponse , Product } from '../../../../client/common/types' ;
15
12
import { DataScience } from '../../../../client/common/utils/localize' ;
16
13
import { Architecture } from '../../../../client/common/utils/platform' ;
14
+ import {
15
+ InterpreterJupyterKernelSpecCommand ,
16
+ JupyterCommandFactory
17
+ } from '../../../../client/datascience/jupyter/interpreter/jupyterCommand' ;
17
18
import {
18
19
JupyterInterpreterDependencyResponse ,
19
20
JupyterInterpreterDependencyService
20
21
} from '../../../../client/datascience/jupyter/interpreter/jupyterInterpreterDependencyService' ;
22
+ import { IJupyterCommand , IJupyterCommandFactory } from '../../../../client/datascience/types' ;
21
23
import { InterpreterType , PythonInterpreter } from '../../../../client/interpreter/contracts' ;
22
24
23
- // tslint:disable: max-func-body-length
25
+ // tslint:disable: max-func-body-length no-any
24
26
25
27
suite ( 'Data Science - Jupyter Interpreter Configuration' , ( ) => {
26
28
let configuration : JupyterInterpreterDependencyService ;
27
29
let appShell : IApplicationShell ;
28
30
let installer : IInstaller ;
29
- let pythonExecService : IPythonExecutionService ;
31
+ let commandFactory : IJupyterCommandFactory ;
32
+ let command : IJupyterCommand ;
30
33
const pythonInterpreter : PythonInterpreter = {
31
34
path : '' ,
32
35
architecture : Architecture . Unknown ,
@@ -37,19 +40,19 @@ suite('Data Science - Jupyter Interpreter Configuration', () => {
37
40
setup ( ( ) => {
38
41
appShell = mock ( ApplicationShell ) ;
39
42
installer = mock ( ProductInstaller ) ;
40
- pythonExecService = mock ( PythonExecutionService ) ;
41
- const pythonExecFactory = mock ( PythonExecutionFactory ) ;
42
- when ( pythonExecFactory . createActivatedEnvironment ( anything ( ) ) ) . thenResolve ( instance ( pythonExecService ) ) ;
43
- // tslint:disable-next-line: no- any
44
- instance ( pythonExecService as any ) . then = undefined ;
45
- when ( pythonExecService . execModule ( 'jupyter' , deepEqual ( [ 'kernelspec' , '--version' ] ) , anything ( ) ) ) . thenResolve ( {
46
- stdout : ''
47
- } ) ;
43
+ commandFactory = mock ( JupyterCommandFactory ) ;
44
+ command = mock ( InterpreterJupyterKernelSpecCommand ) ;
45
+ instance ( commandFactory as any ) . then = undefined ;
46
+ instance ( command as any ) . then = undefined ;
47
+ when (
48
+ commandFactory . createInterpreterCommand ( anything ( ) , anything ( ) , anything ( ) , anything ( ) , anything ( ) )
49
+ ) . thenReturn ( instance ( command ) ) ;
50
+ when ( command . exec ( anything ( ) , anything ( ) ) ) . thenResolve ( { stdout : '' } ) ;
48
51
49
52
configuration = new JupyterInterpreterDependencyService (
50
53
instance ( appShell ) ,
51
54
instance ( installer ) ,
52
- instance ( pythonExecFactory )
55
+ instance ( commandFactory )
53
56
) ;
54
57
} ) ;
55
58
test ( 'Return ok if all dependencies are installed' , async ( ) => {
@@ -91,9 +94,7 @@ suite('Data Science - Jupyter Interpreter Configuration', () => {
91
94
// tslint:disable-next-line: no-any
92
95
DataScience . jupyterInstall ( ) as any
93
96
) ;
94
- when ( pythonExecService . execModule ( 'jupyter' , deepEqual ( [ 'kernelspec' , '--version' ] ) , anything ( ) ) ) . thenReject (
95
- new Error ( 'Not found' )
96
- ) ;
97
+ when ( command . exec ( anything ( ) , anything ( ) ) ) . thenReject ( new Error ( 'Not found' ) ) ;
97
98
when ( installer . install ( anything ( ) , anything ( ) , anything ( ) ) ) . thenResolve ( InstallerResponse . Installed ) ;
98
99
99
100
const response = await configuration . installMissingDependencies ( pythonInterpreter ) ;
0 commit comments