Skip to content

Commit a1eec92

Browse files
author
Kartik Raj
committed
Add to proposed API
1 parent 43279fc commit a1eec92

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/client/apiTypes.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Event, Uri } from 'vscode';
55
import { Resource } from './common/types';
66
import { IDataViewerDataProvider, IJupyterUriProvider } from './jupyter/types';
77
import { EnvPathType, PythonEnvKind } from './pythonEnvironments/base/info';
8+
import { ProgressNotificationEvent } from './pythonEnvironments/base/locator';
89

910
/*
1011
* Do not introduce any breaking changes to this API.
@@ -203,6 +204,10 @@ export interface IProposedExtensionAPI {
203204
* is triggered.
204205
*/
205206
refreshEnvironment(options?: RefreshEnvironmentsOptions): Promise<EnvPathType[] | undefined>;
207+
/**
208+
* Fires with details of the current discovery progress, i.e when it starts, finishes or any other relevant stage.
209+
*/
210+
readonly onRefreshProgress: Event<ProgressNotificationEvent>;
206211
/**
207212
* Returns a promise for the ongoing refresh. Returns `undefined` if there are no active
208213
* refreshes going on.

src/client/proposedApi.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export function buildProposedApi(
112112
onDidChangeExecutionDetails: interpreterService.onDidChangeInterpreterConfiguration,
113113
onDidEnvironmentsChanged: onDidInterpretersChangedEvent.event,
114114
onDidActiveEnvironmentChanged: onDidActiveInterpreterChangedEvent.event,
115+
onRefreshProgress: discoveryApi.onProgress,
115116
},
116117
};
117118
return proposed;

src/test/proposedApi.unit.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { IInterpreterPathService } from '../client/common/types';
99
import { IInterpreterService } from '../client/interpreter/contracts';
1010
import { IServiceContainer } from '../client/ioc/types';
1111
import { buildProposedApi } from '../client/proposedApi';
12-
import { IDiscoveryAPI } from '../client/pythonEnvironments/base/locator';
12+
import { IDiscoveryAPI, ProgressNotificationEvent } from '../client/pythonEnvironments/base/locator';
1313
import { PythonEnvironment } from '../client/pythonEnvironments/info';
1414
import { PythonEnvKind, PythonEnvSource } from '../client/pythonEnvironments/base/info';
1515
import { Architecture } from '../client/common/utils/platform';
@@ -21,6 +21,7 @@ suite('Proposed Extension API', () => {
2121
let interpreterPathService: typemoq.IMock<IInterpreterPathService>;
2222
let interpreterService: typemoq.IMock<IInterpreterService>;
2323
let onDidExecutionEvent: Event<Uri | undefined>;
24+
let onRefreshProgress: Event<ProgressNotificationEvent>;
2425

2526
let proposed: IProposedExtensionAPI;
2627

@@ -30,14 +31,21 @@ suite('Proposed Extension API', () => {
3031
interpreterPathService = typemoq.Mock.ofType<IInterpreterPathService>(undefined, typemoq.MockBehavior.Strict);
3132
interpreterService = typemoq.Mock.ofType<IInterpreterService>(undefined, typemoq.MockBehavior.Strict);
3233
onDidExecutionEvent = typemoq.Mock.ofType<Event<Uri | undefined>>().object;
34+
onRefreshProgress = typemoq.Mock.ofType<Event<ProgressNotificationEvent>>().object;
3335
interpreterService.setup((i) => i.onDidChangeInterpreterConfiguration).returns(() => onDidExecutionEvent);
3436

3537
serviceContainer.setup((s) => s.get(IInterpreterPathService)).returns(() => interpreterPathService.object);
3638
serviceContainer.setup((s) => s.get(IInterpreterService)).returns(() => interpreterService.object);
3739

40+
discoverAPI.setup((d) => d.onProgress).returns(() => onRefreshProgress);
41+
3842
proposed = buildProposedApi(discoverAPI.object, serviceContainer.object);
3943
});
4044

45+
test('Provide a callback for tracking refresh progress', async () => {
46+
assert.deepEqual(proposed.environment.onRefreshProgress, onRefreshProgress);
47+
});
48+
4149
test('Provide a callback which is called when execution details changes', async () => {
4250
assert.deepEqual(onDidExecutionEvent, proposed.environment.onDidChangeExecutionDetails);
4351
});

0 commit comments

Comments
 (0)