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 { InterpreterJupyterKernelSpecCommand , JupyterCommandFactory } from '../../../../client/datascience/jupyter/interpreter/jupyterCommand' ;
17
15
import { JupyterInterpreterDependencyResponse , JupyterInterpreterDependencyService } from '../../../../client/datascience/jupyter/interpreter/jupyterInterpreterDependencyService' ;
16
+ import { IJupyterCommand , IJupyterCommandFactory } from '../../../../client/datascience/types' ;
18
17
import { InterpreterType , PythonInterpreter } from '../../../../client/interpreter/contracts' ;
19
18
20
- // tslint:disable-next-line: max-func-body-length
19
+ // tslint:disable: max-func-body-length no-any
20
+
21
21
suite ( 'Data Science - Jupyter Interpreter Configuration' , ( ) => {
22
22
let configuration : JupyterInterpreterDependencyService ;
23
23
let appShell : IApplicationShell ;
24
24
let installer : IInstaller ;
25
- let pythonExecService : IPythonExecutionService ;
25
+ let commandFactory : IJupyterCommandFactory ;
26
+ let command : IJupyterCommand ;
26
27
const pythonInterpreter : PythonInterpreter = {
27
28
path : '' ,
28
29
architecture : Architecture . Unknown ,
@@ -33,14 +34,14 @@ suite('Data Science - Jupyter Interpreter Configuration', () => {
33
34
setup ( ( ) => {
34
35
appShell = mock ( ApplicationShell ) ;
35
36
installer = mock ( ProductInstaller ) ;
36
- pythonExecService = mock ( PythonExecutionService ) ;
37
- const pythonExecFactory = mock ( PythonExecutionFactory ) ;
38
- when ( pythonExecFactory . createActivatedEnvironment ( anything ( ) ) ) . thenResolve ( instance ( pythonExecService ) ) ;
39
- // tslint:disable-next-line: no- any
40
- instance ( pythonExecService as any ) . then = undefined ;
41
- when ( pythonExecService . execModule ( 'jupyter' , deepEqual ( [ 'kernelspec' , '--version' ] ) , anything ( ) ) ) . thenResolve ( { stdout : '' } ) ;
37
+ commandFactory = mock ( JupyterCommandFactory ) ;
38
+ command = mock ( InterpreterJupyterKernelSpecCommand ) ;
39
+ instance ( commandFactory as any ) . then = undefined ;
40
+ instance ( command as any ) . then = undefined ;
41
+ when ( commandFactory . createInterpreterCommand ( anything ( ) , anything ( ) , anything ( ) , anything ( ) , anything ( ) ) ) . thenReturn ( instance ( command ) ) ;
42
+ when ( command . exec ( anything ( ) , anything ( ) ) ) . thenResolve ( { stdout : '' } ) ;
42
43
43
- configuration = new JupyterInterpreterDependencyService ( instance ( appShell ) , instance ( installer ) , instance ( pythonExecFactory ) ) ;
44
+ configuration = new JupyterInterpreterDependencyService ( instance ( appShell ) , instance ( installer ) , instance ( commandFactory ) ) ;
44
45
} ) ;
45
46
test ( 'Return ok if all dependencies are installed' , async ( ) => {
46
47
when ( installer . isInstalled ( Product . jupyter , pythonInterpreter ) ) . thenResolve ( true ) ;
@@ -72,7 +73,7 @@ suite('Data Science - Jupyter Interpreter Configuration', () => {
72
73
// tslint:disable-next-line: no-any
73
74
DataScience . jupyterInstall ( ) as any
74
75
) ;
75
- when ( pythonExecService . execModule ( 'jupyter' , deepEqual ( [ 'kernelspec' , '--version' ] ) , anything ( ) ) ) . thenReject ( new Error ( 'Not found' ) ) ;
76
+ when ( command . exec ( anything ( ) , anything ( ) ) ) . thenReject ( new Error ( 'Not found' ) ) ;
76
77
when ( installer . install ( anything ( ) , anything ( ) , anything ( ) ) ) . thenResolve ( InstallerResponse . Installed ) ;
77
78
78
79
const response = await configuration . installMissingDependencies ( pythonInterpreter ) ;
0 commit comments