Skip to content

Commit 367ce59

Browse files
committed
refinement based on my comments
1 parent 482e7d9 commit 367ce59

4 files changed

Lines changed: 45 additions & 402 deletions

File tree

src/test/integration/envCreation.integration.test.ts

Lines changed: 15 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -42,70 +42,29 @@ suite('Integration: Environment Creation', function () {
4242

4343
api = extension.exports as PythonEnvironmentApi;
4444
assert.ok(api, 'API not available');
45-
});
46-
47-
/**
48-
* Test: createEnvironment API is available
49-
*
50-
* The API should have a createEnvironment method.
51-
*/
52-
test('createEnvironment API is available', async function () {
5345
assert.ok(typeof api.createEnvironment === 'function', 'createEnvironment should be a function');
54-
});
55-
56-
/**
57-
* Test: removeEnvironment API is available
58-
*
59-
* The API should have a removeEnvironment method.
60-
*/
61-
test('removeEnvironment API is available', async function () {
6246
assert.ok(typeof api.removeEnvironment === 'function', 'removeEnvironment should be a function');
6347
});
6448

65-
/**
66-
* Test: Managers that support creation are available
67-
*
68-
* At least one environment manager (venv or conda) should support creation.
69-
* This test verifies that global Python installations are discoverable.
70-
*/
71-
test('At least one manager supports environment creation', async function () {
72-
// Get all environments to force managers to load
73-
await api.getEnvironments('all');
74-
75-
// Check if we have global Python installations that can create venvs
76-
const globalEnvs = await api.getEnvironments('global');
77-
78-
// Assert we have at least one global Python that can serve as base for venv creation
79-
assert.ok(
80-
globalEnvs.length > 0,
81-
'At least one global Python installation should be available for environment creation. ' +
82-
'If this fails, ensure Python is installed and discoverable on this system.',
83-
);
84-
85-
// Verify the global environments have required properties for creation
86-
for (const env of globalEnvs) {
87-
assert.ok(env.envId, 'Global environment must have envId');
88-
assert.ok(env.environmentPath, 'Global environment must have environmentPath');
89-
}
90-
91-
console.log(`Found ${globalEnvs.length} global Python installations for venv creation`);
92-
});
49+
// =========================================================================
50+
// ENVIRONMENT CREATION BEHAVIOR TESTS
51+
// These tests verify actual user-facing creation and removal workflows.
52+
// =========================================================================
9353

9454
/**
9555
* Test: Created environment appears in discovery
9656
*
97-
* After creating an environment, it should be discoverable via getEnvironments.
98-
* This test creates a real environment and cleans it up.
57+
* BEHAVIOR TESTED: User creates an environment via quickCreate,
58+
* then the environment should be discoverable via getEnvironments.
9959
*/
10060
test('Created environment appears in discovery', async function () {
61+
// --- SETUP: Ensure we have prerequisites ---
10162
const workspaceFolders = vscode.workspace.workspaceFolders;
102-
10363
if (!workspaceFolders || workspaceFolders.length === 0) {
10464
this.skip();
10565
return;
10666
}
10767

108-
// Check if we have Python available for venv creation
10968
const globalEnvs = await api.getEnvironments('global');
11069
if (globalEnvs.length === 0) {
11170
console.log('No global Python installations found, skipping creation test');
@@ -117,17 +76,16 @@ suite('Integration: Environment Creation', function () {
11776
let createdEnv: PythonEnvironment | undefined;
11877

11978
try {
120-
// Create environment with quickCreate to avoid prompts
79+
// --- ACTION: User creates environment ---
12180
createdEnv = await api.createEnvironment(workspaceUri, { quickCreate: true });
12281

12382
if (!createdEnv) {
124-
// Creation may have been cancelled or failed silently
12583
console.log('Environment creation returned undefined (may require user input)');
12684
this.skip();
12785
return;
12886
}
12987

130-
// Refresh and verify the environment appears
88+
// --- VERIFY: Created environment is discoverable ---
13189
await api.refreshEnvironments(workspaceUri);
13290
const environments = await api.getEnvironments(workspaceUri);
13391

@@ -153,11 +111,12 @@ suite('Integration: Environment Creation', function () {
153111
/**
154112
* Test: Environment removal removes from discovery
155113
*
156-
* After removing an environment, it should no longer appear in discovery.
114+
* BEHAVIOR TESTED: User removes an environment, then it should
115+
* no longer appear in discovery results.
157116
*/
158117
test('Removed environment disappears from discovery', async function () {
118+
// --- SETUP: Create an environment to remove ---
159119
const workspaceFolders = vscode.workspace.workspaceFolders;
160-
161120
if (!workspaceFolders || workspaceFolders.length === 0) {
162121
this.skip();
163122
return;
@@ -173,25 +132,21 @@ suite('Integration: Environment Creation', function () {
173132
let createdEnv: PythonEnvironment | undefined;
174133

175134
try {
176-
// Create environment
177135
createdEnv = await api.createEnvironment(workspaceUri, { quickCreate: true });
178-
179136
if (!createdEnv) {
180137
this.skip();
181138
return;
182139
}
183140

184-
// Record the environment ID
185141
const envId = createdEnv.envId.id;
186142

187-
// Remove environment
143+
// --- ACTION: User removes environment ---
188144
await api.removeEnvironment(createdEnv);
189-
createdEnv = undefined; // Mark as cleaned up
145+
createdEnv = undefined;
190146

191-
// Give time for removal to complete
192147
await sleep(1000);
193148

194-
// Refresh and verify it's gone
149+
// --- VERIFY: Environment is no longer discoverable ---
195150
await api.refreshEnvironments(workspaceUri);
196151
const environments = await api.getEnvironments(workspaceUri);
197152

src/test/integration/envManagerApi.integration.test.ts

Lines changed: 0 additions & 165 deletions
This file was deleted.

src/test/integration/multiroot/multiWorkspace.integration.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ suite('Integration: Multi-Root Workspace', function () {
138138
/**
139139
* Test: Workspace folder settings scope is respected
140140
*
141-
* Settings at workspace folder level should be independently inspectable
141+
* Settings at workspace folder level should be independently accessible
142142
* across different folders.
143143
*/
144144
test('Workspace folder settings scope is respected', async function () {
@@ -147,7 +147,7 @@ suite('Integration: Multi-Root Workspace', function () {
147147
const config1 = vscode.workspace.getConfiguration('python-envs', workspaceFolders[0].uri);
148148
const config2 = vscode.workspace.getConfiguration('python-envs', workspaceFolders[1].uri);
149149

150-
// Both should be independently inspectable
150+
// Both should be independently accessible via inspect()
151151
const inspect1 = config1.inspect('pythonProjects');
152152
const inspect2 = config2.inspect('pythonProjects');
153153

0 commit comments

Comments
 (0)