|
1 | 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
2 | 2 | // Licensed under the MIT License. |
3 | 3 |
|
| 4 | +import { expect } from 'chai'; |
4 | 5 | import * as path from 'path'; |
5 | 6 | import * as sinon from 'sinon'; |
6 | 7 | import { ExecutionResult, ShellOptions } from '../../../../client/common/process/types'; |
7 | 8 | import { PythonEnvKind } from '../../../../client/pythonEnvironments/base/info'; |
| 9 | +import { ILocator } from '../../../../client/pythonEnvironments/base/locator'; |
| 10 | +import { getEnvs } from '../../../../client/pythonEnvironments/base/locatorUtils'; |
8 | 11 | import * as externalDependencies from '../../../../client/pythonEnvironments/common/externalDependencies'; |
9 | 12 | import { PoetryLocator } from '../../../../client/pythonEnvironments/discovery/locators/services/poetryLocator'; |
| 13 | +import { EXTENSION_ROOT_DIR_FOR_TESTS } from '../../../constants'; |
10 | 14 | import { TEST_LAYOUT_ROOT } from '../../common/commonTestConstants'; |
11 | 15 | import { testLocatorWatcher } from './watcherTestUtils'; |
12 | 16 |
|
13 | | -suite('Poetry Locator', async () => { |
| 17 | +suite('Poetry Watcher', async () => { |
14 | 18 | let shellExecute: sinon.SinonStub; |
15 | 19 | const testPoetryDir = path.join(TEST_LAYOUT_ROOT, 'poetry'); |
16 | 20 | const project1 = path.join(testPoetryDir, 'project1'); |
@@ -38,3 +42,23 @@ suite('Poetry Locator', async () => { |
38 | 42 |
|
39 | 43 | suiteTeardown(() => sinon.restore()); |
40 | 44 | }); |
| 45 | + |
| 46 | +suite('Poetry Locator', async function () { |
| 47 | + let locator: ILocator; |
| 48 | + suiteSetup(async function () { |
| 49 | + if (process.env.CI_PYTHON_VERSION && process.env.CI_PYTHON_VERSION.startsWith('2.')) { |
| 50 | + // Poetry is soon to be deprecated for Python2.7, and tests do not pass |
| 51 | + // as it is with pip installation of poetry, hence skip. |
| 52 | + this.skip(); |
| 53 | + } |
| 54 | + locator = new PoetryLocator(EXTENSION_ROOT_DIR_FOR_TESTS); |
| 55 | + }); |
| 56 | + |
| 57 | + test('Discovers existing poetry environments', async () => { |
| 58 | + const items = await getEnvs(locator.iterEnvs()); |
| 59 | + const isLocated = items.some( |
| 60 | + (item) => item.kind === PythonEnvKind.Poetry && item.name.startsWith('poetry-tutorial-project'), |
| 61 | + ); |
| 62 | + expect(isLocated).to.equal(true); |
| 63 | + }); |
| 64 | +}); |
0 commit comments