Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_pipeline_create_and_variables_test Fix #1184

Merged
merged 9 commits into from
Sep 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/authoring_tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
Make sure your machine python SDK cache is clear. It is located at `%userprofile%\.azure-devops\python-sdk\cache\`
While running the test localy for first time make sure that the cassest (in the recording folder) gets the resource call as well

## Logout from az cli

Do `az logout` so that PAT token can be used.
If you don't logout, system will not take PAT for Authentication, which will result into test fail in PR pipeline.

## Configure PAT for running live tests

Recommended way is to use PAT from environment variable (AZURE_DEVOPS_EXT_PAT) when running a live test, so your PAT in the test file does not accidently get exposed to public in a PR.
Expand Down
2,065 changes: 763 additions & 1,302 deletions tests/recordings/test_pipeline_create_and_variables_test.yaml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/test_pipelinesCreateAndVariablesTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from azure_devtools.scenario_tests import AllowLargeResponse
from .utilities.helper import DevopsScenarioTest, disable_telemetry, set_authentication, get_test_org_from_env_variable

DEVOPS_CLI_TEST_ORGANIZATION = get_test_org_from_env_variable() or 'Https://dev.azure.com/azuredevopsclitest'
DEVOPS_CLI_TEST_ORGANIZATION = get_test_org_from_env_variable() or 'Https://dev.azure.com/devops-cli-test-org'

class PipelinesTests(DevopsScenarioTest):
@AllowLargeResponse(size_kb=3072)
Expand All @@ -34,7 +34,7 @@ def test_pipeline_create_and_variables_test(self):
created_repo_name = list_repo_output[0]["name"]

# Import repo with yaml file
import_repo_command = 'az repos import create --git-source-url https://dev.azure.com/AzureDevOpsCliTest/ImportRepoTest/_git/snakes-and-ladders --repository ' + created_repo_id + ' --detect false --output json'
import_repo_command = 'az repos import create --git-source-url https://dev.azure.com/devops-cli-test-org/TestSupportProject/_git/snakes-and-ladders --repository ' + created_repo_id + ' --detect false --output json'
import_repo_output = self.cmd(import_repo_command).get_output_in_json()
import_repo_status = import_repo_output["status"]
assert import_repo_status == 'completed'
Expand All @@ -43,7 +43,7 @@ def test_pipeline_create_and_variables_test(self):
PIPELINE_NAME = 'ContosoBuild'
PIPELINE_DESCRIPTION = 'Pipeline for contoso project'
pipeline_create_command = 'az pipelines create --name {} --description "{}" --repository {} \
--repository-type tfsgit --branch master --yml-path azure-pipelines.yml --detect false \
--repository-type tfsgit --branch main --yml-path azure-pipelines.yml --detect false \
--output json'.format(PIPELINE_NAME, PIPELINE_DESCRIPTION, created_repo_name)
pipeline_create_output = self.cmd(pipeline_create_command).get_output_in_json()
created_pipeline_id = pipeline_create_output['definition']['id']
Expand Down