Skip to content

Commit 42b36d0

Browse files
committed
update to new package api
1 parent ef298a0 commit 42b36d0

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

src/features/copilotTools.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
Uri,
1010
} from 'vscode';
1111
import {
12+
PackageManagementOptions,
1213
PythonEnvironment,
1314
PythonEnvironmentExecutionInfo,
1415
PythonPackageGetterApi,
@@ -205,7 +206,10 @@ export class InstallPackageTool implements LanguageModelTool<IInstallPackageInpu
205206
}
206207

207208
// Install the packages
208-
await this.api.installPackages(environment, parameters.packageList);
209+
const pkgManagementOptions: PackageManagementOptions = {
210+
install: parameters.packageList,
211+
};
212+
await this.api.managePackages(environment, pkgManagementOptions);
209213
const resultMessage = `Successfully installed ${packagePlurality}: ${parameters.packageList.join(', ')}`;
210214

211215
deferredReturn.resolve({

src/test/copilotTools.unit.test.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ suite('InstallPackageTool Tests', () => {
3535
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3636
mockEnvironment.setup((x: any) => x.then).returns(() => undefined);
3737

38-
// refresh will always return a resolved promise
39-
mockApi.setup((x) => x.refreshPackages(typeMoq.It.isAny())).returns(() => Promise.resolve());
40-
4138
// Create an instance of InstallPackageTool with the mock functions
4239
installPackageTool = new InstallPackageTool(mockApi.object);
4340
});
@@ -114,8 +111,6 @@ suite('InstallPackageTool Tests', () => {
114111
return Promise.resolve(mockEnvironment.object);
115112
});
116113

117-
mockApi.setup((x) => x.refreshPackages(typeMoq.It.isAny())).returns(() => Promise.resolve());
118-
119114
const options = { input: testFile, toolInvocationToken: undefined };
120115
const tokenSource = new vscode.CancellationTokenSource();
121116
const token = tokenSource.token;
@@ -145,9 +140,8 @@ suite('InstallPackageTool Tests', () => {
145140
return Promise.resolve(mockEnvironment.object);
146141
});
147142

148-
mockApi.setup((x) => x.refreshPackages(typeMoq.It.isAny())).returns(() => Promise.resolve());
149143
mockApi
150-
.setup((x) => x.installPackages(typeMoq.It.isAny(), typeMoq.It.isAny()))
144+
.setup((x) => x.managePackages(typeMoq.It.isAny(), typeMoq.It.isAny()))
151145
.returns(() => {
152146
const deferred = createDeferred<void>();
153147
deferred.resolve();
@@ -177,9 +171,8 @@ suite('InstallPackageTool Tests', () => {
177171
return Promise.resolve(mockEnvironment.object);
178172
});
179173

180-
mockApi.setup((x) => x.refreshPackages(typeMoq.It.isAny())).returns(() => Promise.resolve());
181174
mockApi
182-
.setup((x) => x.installPackages(typeMoq.It.isAny(), typeMoq.It.isAny()))
175+
.setup((x) => x.managePackages(typeMoq.It.isAny(), typeMoq.It.isAny()))
183176
.returns(() => {
184177
const deferred = createDeferred<void>();
185178
deferred.reject(new Error('Installation failed'));
@@ -228,9 +221,8 @@ suite('InstallPackageTool Tests', () => {
228221
.returns(async () => {
229222
return Promise.resolve(mockEnvironment.object);
230223
});
231-
mockApi.setup((x) => x.refreshPackages(typeMoq.It.isAny())).returns(() => Promise.resolve());
232224
mockApi
233-
.setup((x) => x.installPackages(typeMoq.It.isAny(), typeMoq.It.isAny()))
225+
.setup((x) => x.managePackages(typeMoq.It.isAny(), typeMoq.It.isAny()))
234226
.returns(() => {
235227
const deferred = createDeferred<void>();
236228
deferred.resolve();

0 commit comments

Comments
 (0)