Initial checkin for pytest integration

This commit is contained in:
Omar Zevallos 2018-12-31 15:58:20 -05:00
Родитель 50abd47cab
Коммит 0ff9080832
3 изменённых файлов: 42 добавлений и 2 удалений

Просмотреть файл

@ -11,11 +11,13 @@ steps:
inputs:
versionSpec: '3.7'
architecture: 'x64'
- script: |
python3 --version
pip install --upgrade pip setuptools wheel
pip install -r test/requirements.txt
displayName: 'Install Python Dependencies'
- script: |
az login --service-principal -u $AZURE_CLIENT_ID -p $AZURE_CLIENT_SECRET --tenant $AZURE_TENANT_ID
displayName: 'Authenticate Service Principal'
@ -23,6 +25,7 @@ steps:
AZURE_TENANT_ID: $(SPTENANTID)
AZURE_CLIENT_ID: $(SPAPPID)
AZURE_CLIENT_SECRET: $(SPPW)
- script: |
python3 test/test_avere_template_deploy.py --skip-az-ops
displayName: 'Test Avere vFXT template-based deployment'
@ -32,4 +35,24 @@ steps:
AZURE_TENANT_ID: $(SPTENANTID)
AZURE_CLIENT_ID: $(SPAPPID)
AZURE_CLIENT_SECRET: $(SPPW)
AZURE_SUBSCRIPTION_ID: $(AZURE-SUBSCRIPTION-ID)
AZURE_SUBSCRIPTION_ID: $(AZURE-SUBSCRIPTION-ID)
- bash: echo "##vso[task.prependpath]/usr/share/miniconda/bin"
displayName: Add conda to PATH
- bash: |
conda create --yes --quiet --name myEnvironment python=3.7
displayName: Create Anaconda environment
- script: |
source activate myEnvironment
pip install pytest
pip install pytest-cov
pytest test/test_avere_template_deploy.py --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
displayName: '(pytest) Test Avere vFXT template-based deployment'
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFiles: 'junit/test-results.xml'
testRunTitle: 'Publish test results for Python $(python.version)'

Просмотреть файл

@ -26,7 +26,7 @@ from azure.mgmt.resource.resources.models import DeploymentMode
class AvereTemplateDeploy:
def __init__(self, deploy_params={}, resource_group=None,
location='eastus2', debug=True):
location='eastus2', debug=False):
"""Initialize, authenticate to Azure, generate deploy params."""
self._template_url = 'https://raw.githubusercontent.com/Azure/Avere/master/src/vfxt/azuredeploy-auto.json'
self.debug = debug

Просмотреть файл

@ -12,6 +12,23 @@ import time
from avere_template_deploy import AvereTemplateDeploy
# TEST CASES ##################################################################
class TestDeployment:
atd = AvereTemplateDeploy()
def test_create_resource_group(self):
rg = TestDeployment.atd.create_resource_group()
print('> Created Resource Group: {}'.format(rg))
def test_deploy_template(self):
# 2018-1231: TURNED OFF FOR NOW
# wait_for_op(TestDeployment.atd.deploy())
pass
def test_delete_resource_group(self):
wait_for_op(TestDeployment.atd.delete_resource_group())
# HELPER FUNCTIONS ############################################################
def wait_for_op(op, timeout_sec=60):