Skip to content

Commit c16e242

Browse files
edvilmeCopilot
andcommitted
Remove capability tests that duplicate existing package-manager routing coverage
getPackageManagerCapability resolves its manager via the same PythonEnvironmentManagers.getPackageManager routing already used by getPackages/managePackages/refreshPackages, and already exhaustively tested in packageManager.api.unit.test.ts. Several tests in extensionApi.capabilities.unit.test.ts re-exercised that same pre-existing routing (project inference, ambiguous/missing project fallback prevention) through the new capability entry point without testing anything specific to capability advertisement: - 'queries the preferred non-project package provider without project inference' duplicated the project-independent manager tests. - 'environment routing infers a unique project and selects its different configured provider' duplicated the unique-project resolution test. - 'does not fall back to a project-aware root with 0/2 matching projects' duplicated the ambiguous/missing project tests. Simplified 'a missing configured provider cannot fall back to the preferred root' to only cover the explicit-project path, which is genuinely new (no other package method accepts an explicit project override), dropping the environment-only variant that duplicated the existing undefined-manager-id lookup behavior. Removed the now-unused getLastKnownEnvironment stub that only the deleted tests relied on. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 9ca924d commit c16e242

1 file changed

Lines changed: 2 additions & 42 deletions

File tree

‎src/test/extensionApi.capabilities.unit.test.ts‎

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ suite('PythonEnvironmentApiImpl - capability queries', () => {
4444
let disposables: Disposable[];
4545
let getExtension: sinon.SinonStub;
4646
let configuredPackage: sinon.SinonStub;
47-
let selectedEnvironment: sinon.SinonStub;
4847
let envProbe: sinon.SinonStub<[CapabilityContext], Promise<Support>>;
4948
let pkgProbe: sinon.SinonStub<[CapabilityContext], Promise<Support>>;
5049
let scopedProbe: sinon.SinonStub<[CapabilityContext], Promise<Support>>;
@@ -69,7 +68,6 @@ suite('PythonEnvironmentApiImpl - capability queries', () => {
6968
onDidChangeProjects: projectChanges.event,
7069
} as unknown as PythonProjectManager;
7170
managers = new PythonEnvironmentManagers(projectManager);
72-
selectedEnvironment = sinon.stub(managers, 'getLastKnownEnvironment').returns(environment);
7371
type ApiArgs = ConstructorParameters<typeof PythonEnvironmentApiImpl>;
7472
api = new PythonEnvironmentApiImpl(
7573
managers,
@@ -170,15 +168,6 @@ suite('PythonEnvironmentApiImpl - capability queries', () => {
170168
await assert.rejects(api.getPackageManagerCapability(environment, 'packages.list'), (error) => error === failure);
171169
});
172170

173-
test('queries the preferred non-project package provider without project inference', async () => {
174-
projects = [];
175-
registerOwner();
176-
registerPackages();
177-
assert.strictEqual((await api.getPackageManagerCapability(environment, 'packages.list')).supported, true);
178-
assert.strictEqual(pkgProbe.firstCall.args[0].environment, environment);
179-
assert.ok(selectedEnvironment.notCalled);
180-
});
181-
182171
test('explicit project selects its configured scoped provider without a registered owner', async () => {
183172
configuredPackage.returns(`${extensionId}:configured`);
184173
const create = registerPackages(true, 'configured');
@@ -189,18 +178,6 @@ suite('PythonEnvironmentApiImpl - capability queries', () => {
189178
assert.ok(configuredPackage.calledWithExactly(projectManager, project.uri));
190179
});
191180

192-
test('environment routing infers a unique project and selects its different configured provider', async () => {
193-
registerOwner();
194-
const preferredFactory = registerPackages(true);
195-
configuredPackage.returns(`${extensionId}:configured`);
196-
const configuredFactory = registerPackages(true, 'configured');
197-
assert.strictEqual(await api.getPackageManagerCapability(environment, 'packages.list'), scopedSupport);
198-
assert.ok(preferredFactory?.notCalled);
199-
assert.ok(configuredFactory?.calledOnceWithExactly(project));
200-
assert.ok(scopedProbe.calledOnceWithExactly({ environment, project }));
201-
assert.ok(pkgProbe.notCalled);
202-
});
203-
204181
test('environment-only package queries are unavailable until both providers register', async () => {
205182
const support = await api.getPackageManagerCapability(environment, 'packages.list');
206183
assert.ok(!support.supported && support.reason.length > 0);
@@ -213,21 +190,6 @@ suite('PythonEnvironmentApiImpl - capability queries', () => {
213190
assert.strictEqual((await api.getPackageManagerCapability(environment, 'packages.list')).supported, true);
214191
});
215192

216-
for (const matchingProjects of [0, 2]) {
217-
test(`does not fall back to a project-aware root with ${matchingProjects} matching projects`, async () => {
218-
projects =
219-
matchingProjects === 0
220-
? []
221-
: [project, { name: 'second', uri: Uri.joinPath(Uri.file(process.cwd()), 'second') }];
222-
registerOwner();
223-
const create = registerPackages(true);
224-
const support = await api.getPackageManagerCapability(environment, 'packages.list');
225-
assert.ok(!support.supported && support.reason.length > 0);
226-
assert.ok(create?.notCalled);
227-
assert.ok(pkgProbe.notCalled);
228-
});
229-
}
230-
231193
test('an untracked explicit project never probes a project-aware root', async () => {
232194
projects = [];
233195
registerPackages(true);
@@ -239,10 +201,8 @@ suite('PythonEnvironmentApiImpl - capability queries', () => {
239201
registerOwner();
240202
const create = registerPackages(true);
241203
configuredPackage.returns(`${extensionId}:missing`);
242-
for (const explicitProject of [undefined, project]) {
243-
const support = await api.getPackageManagerCapability(environment, 'packages.list', explicitProject);
244-
assert.ok(!support.supported && support.reason.length > 0);
245-
}
204+
const support = await api.getPackageManagerCapability(environment, 'packages.list', project);
205+
assert.ok(!support.supported && support.reason.length > 0);
246206
assert.ok(create?.notCalled);
247207
assert.ok(pkgProbe.notCalled);
248208
});

0 commit comments

Comments
 (0)