@@ -11,24 +11,20 @@ import { IApplicationShell } from '../../../client/common/application/types';
1111import { PersistentState , PersistentStateFactory } from '../../../client/common/persistentState' ;
1212import { IPersistentStateFactory } from '../../../client/common/types' ;
1313import { Python27Support , Common } from '../../../client/common/utils/localize' ;
14- import { IInterpreterService } from '../../../client/interpreter/contracts' ;
1514import { Python27SupportPrompt } from '../../../client/interpreter/display/python27Prompt' ;
16- import { InterpreterService } from '../../../client/interpreter/interpreterService' ;
1715import { PythonEnvironment } from '../../../client/pythonEnvironments/info' ;
1816import * as Telemetry from '../../../client/telemetry' ;
1917import { EventName } from '../../../client/telemetry/constants' ;
2018
2119suite ( 'Python 2.7 support prompt' , ( ) => {
2220 let applicationShell : IApplicationShell ;
23- let interpreterService : IInterpreterService ;
2421 let persistentStateFactory : IPersistentStateFactory ;
2522 let state : PersistentState < boolean > ;
2623 let sendTelemetryEventStub : sinon . SinonStub ;
2724 let telemetryEvents : { eventName : string ; properties : Record < string , unknown > } [ ] = [ ] ;
2825
2926 setup ( ( ) => {
3027 applicationShell = mock ( ApplicationShell ) ;
31- interpreterService = mock ( InterpreterService ) ;
3228 persistentStateFactory = mock ( PersistentStateFactory ) ;
3329 state = mock ( PersistentState ) as PersistentState < boolean > ;
3430
@@ -56,38 +52,33 @@ suite('Python 2.7 support prompt', () => {
5652 type TestCaseType = {
5753 doNotShow : boolean ;
5854 interpreter : { version : { major : number ; minor : number } } ;
59- getActiveInterpreterCalled : boolean ;
6055 expected : boolean ;
6156 } ;
6257
6358 const testCases : TestCaseType [ ] = [
6459 {
6560 doNotShow : false ,
6661 interpreter : { version : { major : 2 , minor : 7 } } ,
67- getActiveInterpreterCalled : true ,
6862 expected : true ,
6963 } ,
7064 {
7165 doNotShow : false ,
7266 interpreter : { version : { major : 3 , minor : 9 } } ,
73- getActiveInterpreterCalled : true ,
7467 expected : false ,
7568 } ,
7669 {
7770 doNotShow : true ,
7871 interpreter : { version : { major : 2 , minor : 7 } } ,
79- getActiveInterpreterCalled : false ,
8072 expected : false ,
8173 } ,
8274 {
8375 doNotShow : true ,
8476 interpreter : { version : { major : 3 , minor : 9 } } ,
85- getActiveInterpreterCalled : false ,
8677 expected : false ,
8778 } ,
8879 ] ;
8980
90- testCases . forEach ( ( { doNotShow, interpreter, getActiveInterpreterCalled , expected } ) => {
81+ testCases . forEach ( ( { doNotShow, interpreter, expected } ) => {
9182 const testTitle = `Should${
9283 ! expected ? ' not' : ''
9384 } show prompt if do not show is ${ doNotShow } and interpreter is ${ interpreter . version . major } .${
@@ -96,35 +87,29 @@ suite('Python 2.7 support prompt', () => {
9687
9788 test ( testTitle , async ( ) => {
9889 when ( state . value ) . thenReturn ( doNotShow ) ;
99- when ( interpreterService . getActiveInterpreter ( anything ( ) ) ) . thenResolve ( interpreter as PythonEnvironment ) ;
10090
10191 const python27SupportPrompt = new Python27SupportPrompt (
10292 instance ( applicationShell ) ,
103- instance ( interpreterService ) ,
10493 instance ( persistentStateFactory ) ,
10594 ) ;
10695
107- const result = await python27SupportPrompt . shouldShowPrompt ( ) ;
96+ const result = await python27SupportPrompt . shouldShowPrompt ( interpreter as PythonEnvironment ) ;
10897
10998 assert . strictEqual ( result , expected ) ;
110- if ( getActiveInterpreterCalled ) {
111- verify ( interpreterService . getActiveInterpreter ( anything ( ) ) ) . once ( ) ;
112- } else {
113- verify ( interpreterService . getActiveInterpreter ( anything ( ) ) ) . never ( ) ;
114- }
11599 } ) ;
116100 } ) ;
117101
118102 test ( 'Should not show prompt if it has been shown earlier in the session' , async ( ) => {
119103 const python27SupportPrompt = new Python27SupportPrompt (
120104 instance ( applicationShell ) ,
121- instance ( interpreterService ) ,
122105 instance ( persistentStateFactory ) ,
123106 ) ;
124107
125108 await python27SupportPrompt . showPrompt ( ) ;
126109
127- const result = await python27SupportPrompt . shouldShowPrompt ( ) ;
110+ const result = await python27SupportPrompt . shouldShowPrompt ( {
111+ version : { major : 2 , minor : 7 } ,
112+ } as PythonEnvironment ) ;
128113
129114 assert . strictEqual ( result , false ) ;
130115 } ) ;
@@ -146,7 +131,6 @@ suite('Python 2.7 support prompt', () => {
146131
147132 const python27SupportPrompt = new Python27SupportPrompt (
148133 instance ( appShell ) ,
149- instance ( interpreterService ) ,
150134 instance ( persistentStateFactory ) ,
151135 ) ;
152136
@@ -164,7 +148,6 @@ suite('Python 2.7 support prompt', () => {
164148
165149 const python27SupportPrompt = new Python27SupportPrompt (
166150 instance ( appShell ) ,
167- instance ( interpreterService ) ,
168151 instance ( persistentStateFactory ) ,
169152 ) ;
170153
@@ -176,7 +159,6 @@ suite('Python 2.7 support prompt', () => {
176159 test ( 'Telemetry event should be sent when prompt is shown' , async ( ) => {
177160 const python27SupportPrompt = new Python27SupportPrompt (
178161 instance ( applicationShell ) ,
179- instance ( interpreterService ) ,
180162 instance ( persistentStateFactory ) ,
181163 ) ;
182164
0 commit comments