Skip to content

Commit

Permalink
Add smoke tests using real poetry for discovery (#15930)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Raj authored Apr 13, 2021
1 parent 00d1091 commit 45681f1
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 1 deletion.
10 changes: 10 additions & 0 deletions .github/workflows/insiders.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,16 @@ jobs:
python -m pip install pipenv
python -m pipenv run python ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} pipenvPath
- name: Prepare poetry for venv tests
env:
TEST_FILES_SUFFIX: testvirtualenvs
shell: pwsh
if: matrix.test-suite == 'venv'
run: |
python -m pip install poetry
Move-Item -Path ".\build\ci\pyproject.toml" -Destination .
poetry env use python
- name: Prepare virtualenv for venv tests
env:
TEST_FILES_SUFFIX: testvirtualenvs
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/nightly-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ jobs:
python -m pip install pipenv
python -m pipenv run python ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} pipenvPath
- name: Prepare poetry for venv tests
env:
TEST_FILES_SUFFIX: testvirtualenvs
shell: pwsh
if: matrix.test-suite == 'venv'
run: |
python -m pip install poetry
Move-Item -Path ".\build\ci\pyproject.toml" -Destination .
poetry env use python
- name: Prepare virtualenv for venv tests
env:
TEST_FILES_SUFFIX: testvirtualenvs
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,16 @@ jobs:
python -m pip install pipenv
python -m pipenv run python ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} pipenvPath
- name: Prepare poetry for venv tests
env:
TEST_FILES_SUFFIX: testvirtualenvs
shell: pwsh
if: matrix.test-suite == 'venv'
run: |
python -m pip install poetry
Move-Item -Path ".\build\ci\pyproject.toml" -Destination .
poetry env use python
- name: Prepare virtualenv for venv tests
env:
TEST_FILES_SUFFIX: testvirtualenvs
Expand Down Expand Up @@ -485,6 +495,15 @@ jobs:
python -m pip install pipenv
python -m pipenv run python ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} pipenvPath
- name: Prepare poetry for venv tests
env:
TEST_FILES_SUFFIX: testvirtualenvs
shell: pwsh
run: |
python -m pip install poetry
Move-Item -Path ".\build\ci\pyproject.toml" -Destination .
poetry env use python
- name: Prepare virtualenv for venv tests
env:
TEST_FILES_SUFFIX: testvirtualenvs
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pr-file-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
prereq-pattern: src/**/*.ts
file-pattern: |
src/**/*.test.ts
src/**/*.testvirtualenvs.ts
.github/test_plan.md
skip-label: 'skip tests'
failure-message: 'TypeScript code was edited without also editing a ${file-pattern} file; see the Testing page in our wiki on testing guidelines (the ${skip-label} label can be used to pass this check)'
10 changes: 10 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ jobs:
python -m pip install pipenv
python -m pipenv run python ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} pipenvPath
- name: Prepare poetry for venv tests
env:
TEST_FILES_SUFFIX: testvirtualenvs
shell: pwsh
if: matrix.test-suite == 'venv'
run: |
python -m pip install poetry
Move-Item -Path ".\build\ci\pyproject.toml" -Destination .
poetry env use python
- name: Prepare virtualenv for venv tests
env:
TEST_FILES_SUFFIX: testvirtualenvs
Expand Down
8 changes: 8 additions & 0 deletions build/ci/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[tool.poetry]
name = "poetry-tutorial-project"
version = "0.1.0"
description = ""
authors = [""]

[tool.poetry.dependencies]
python = "*"
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import { expect } from 'chai';
import * as path from 'path';
import * as sinon from 'sinon';
import { ExecutionResult, ShellOptions } from '../../../../client/common/process/types';
import { PythonEnvKind } from '../../../../client/pythonEnvironments/base/info';
import { ILocator } from '../../../../client/pythonEnvironments/base/locator';
import { getEnvs } from '../../../../client/pythonEnvironments/base/locatorUtils';
import * as externalDependencies from '../../../../client/pythonEnvironments/common/externalDependencies';
import { PoetryLocator } from '../../../../client/pythonEnvironments/discovery/locators/services/poetryLocator';
import { EXTENSION_ROOT_DIR_FOR_TESTS } from '../../../constants';
import { TEST_LAYOUT_ROOT } from '../../common/commonTestConstants';
import { testLocatorWatcher } from './watcherTestUtils';

suite('Poetry Locator', async () => {
suite('Poetry Watcher', async () => {
let shellExecute: sinon.SinonStub;
const testPoetryDir = path.join(TEST_LAYOUT_ROOT, 'poetry');
const project1 = path.join(testPoetryDir, 'project1');
Expand Down Expand Up @@ -38,3 +42,23 @@ suite('Poetry Locator', async () => {

suiteTeardown(() => sinon.restore());
});

suite('Poetry Locator', async function () {
let locator: ILocator;
suiteSetup(async function () {
if (process.env.CI_PYTHON_VERSION && process.env.CI_PYTHON_VERSION.startsWith('2.')) {
// Poetry is soon to be deprecated for Python2.7, and tests do not pass
// as it is with pip installation of poetry, hence skip.
this.skip();
}
locator = new PoetryLocator(EXTENSION_ROOT_DIR_FOR_TESTS);
});

test('Discovers existing poetry environments', async () => {
const items = await getEnvs(locator.iterEnvs());
const isLocated = items.some(
(item) => item.kind === PythonEnvKind.Poetry && item.name.startsWith('poetry-tutorial-project'),
);
expect(isLocated).to.equal(true);
});
});

0 comments on commit 45681f1

Please sign in to comment.