Коммит
f114035261
|
@ -1,3 +1,6 @@
|
||||||
|
# the test config file
|
||||||
|
tests/_config.py
|
||||||
|
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
|
|
34
LICENSE
34
LICENSE
|
@ -1,21 +1,21 @@
|
||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2018 dolko
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
The above copyright notice and this permission notice shall be included in all
|
||||||
copies or substantial portions of the Software.
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE
|
||||||
|
|
12
README.md
12
README.md
|
@ -42,7 +42,17 @@ This Python library extensively uses the Azure DevOps REST APIs and Azure Devops
|
||||||
|
|
||||||
## Samples
|
## Samples
|
||||||
|
|
||||||
See samples by looking at tests or viewing `az functionapp devops-build -h`.
|
See samples by looking at tests or viewing the az-cli functionapp devops-build module.
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
|
||||||
|
Several things need to be setup before you can run the tests:
|
||||||
|
1. You need to be signed into the az cli. You can do this by using `az login`.
|
||||||
|
2. Since this directly deploys to azure functions you need to create an azure functions functionapp using the azure portal. Make sure you record the details of the subscription name, project name, application type and storage name
|
||||||
|
3.
|
||||||
|
|
||||||
|
|
||||||
|
To run the tests you need to first setup the config file in the tests file. Follow the instructions in there and then run `python -m unittest discover`
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
|
|
|
@ -48,5 +48,14 @@ class BaseManager(object):
|
||||||
return next((definition for definition in definitions if definition.name == definition_name), None)
|
return next((definition for definition in definitions if definition.name == definition_name), None)
|
||||||
|
|
||||||
def _get_build_by_name(self, project, name):
|
def _get_build_by_name(self, project, name):
|
||||||
|
"""Helper function to get build object from its name"""
|
||||||
builds = sorted(self._build_client.get_builds(project=project.id), key=lambda x: x.finish_time, reverse=True)
|
builds = sorted(self._build_client.get_builds(project=project.id), key=lambda x: x.finish_time, reverse=True)
|
||||||
return next((build for build in builds if build.definition.name == name))
|
return next((build for build in builds if build.definition.name == name))
|
||||||
|
|
||||||
|
def _get_github_repository_by_name(self, project, name):
|
||||||
|
"""Helper function to get a github repository object from its name"""
|
||||||
|
service_endpoints = self._service_endpoint_client.get_service_endpoints(project.id)
|
||||||
|
github_endpoint = next((endpoint for endpoint in service_endpoints if endpoint.type == "github"), None)
|
||||||
|
repositories = self._build_client.list_repositories(project.id, 'github', github_endpoint.id)
|
||||||
|
repository_match = next((repository for repository in repositories.repositories if repository.name == name), None)
|
||||||
|
return repository_match
|
||||||
|
|
|
@ -23,16 +23,23 @@ class BuilderManager(BaseManager):
|
||||||
"""Inits BuilderManager as per BaseManager"""
|
"""Inits BuilderManager as per BaseManager"""
|
||||||
super(BuilderManager, self).__init__(creds, organization_name, project_name, repository_name=repository_name)
|
super(BuilderManager, self).__init__(creds, organization_name, project_name, repository_name=repository_name)
|
||||||
|
|
||||||
def create_definition(self, build_definition_name, pool_name):
|
def create_definition(self, build_definition_name, pool_name, github=False):
|
||||||
"""Create a build definition in Azure DevOps"""
|
"""Create a build definition in Azure DevOps"""
|
||||||
project = self._get_project_by_name(self._project_name)
|
project = self._get_project_by_name(self._project_name)
|
||||||
repository = self._get_repository_by_name(project, self._repository_name)
|
|
||||||
pool = self._get_pool_by_name(pool_name)
|
pool = self._get_pool_by_name(pool_name)
|
||||||
|
|
||||||
# create the relevant objects that are needed for the build definition (this is the minimum amount needed)
|
# create the relevant objects that are needed for the build definition (this is the minimum amount needed)
|
||||||
pool_queue = build_models.agent_pool_queue.AgentPoolQueue(id=pool.id, name=pool.name)
|
pool_queue = build_models.agent_pool_queue.AgentPoolQueue(id=pool.id, name=pool.name)
|
||||||
build_repository = build_models.build_repository.BuildRepository(default_branch="master", id=repository.id,
|
if github:
|
||||||
name=repository.name, type="TfsGit")
|
repository = self._get_github_repository_by_name(project, self._repository_name)
|
||||||
|
github_properties = repository.properties
|
||||||
|
build_repository = build_models.build_repository.BuildRepository(default_branch="master", id=repository.id, properties=github_properties,
|
||||||
|
name=repository.full_name, type="GitHub", url=repository.properties['cloneUrl'])
|
||||||
|
|
||||||
|
else:
|
||||||
|
repository = self._get_repository_by_name(project, self._repository_name)
|
||||||
|
build_repository = build_models.build_repository.BuildRepository(default_branch="master", id=repository.id,
|
||||||
|
name=repository.name, type="TfsGit")
|
||||||
team_project_reference = self._get_project_reference(project)
|
team_project_reference = self._get_project_reference(project)
|
||||||
build_definition = self._get_build_definition(team_project_reference, build_repository,
|
build_definition = self._get_build_definition(team_project_reference, build_repository,
|
||||||
build_definition_name, pool_queue)
|
build_definition_name, pool_queue)
|
||||||
|
|
|
@ -25,6 +25,7 @@ class ProjectManager(BaseManager):
|
||||||
dserialize: deserializer to process http responses into python classes
|
dserialize: deserializer to process http responses into python classes
|
||||||
Otherwise see BaseManager
|
Otherwise see BaseManager
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, base_url='https://{}.visualstudio.com', organization_name="", creds=None, create_project_url='https://dev.azure.com'):
|
def __init__(self, base_url='https://{}.visualstudio.com', organization_name="", creds=None, create_project_url='https://dev.azure.com'):
|
||||||
"""Inits Project as per BaseManager and adds relevant other needed fields"""
|
"""Inits Project as per BaseManager and adds relevant other needed fields"""
|
||||||
super(ProjectManager, self).__init__(creds, organization_name=organization_name)
|
super(ProjectManager, self).__init__(creds, organization_name=organization_name)
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
# --------------------------------------------------------------------------------------------
|
# --------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
from .repository_response import RepositoryResponse
|
from .repository_response import RepositoryResponse
|
||||||
|
from .github_connection import GithubConnection
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'RepositoryResponse'
|
'RepositoryResponse',
|
||||||
|
'GithubConnection'
|
||||||
]
|
]
|
|
@ -0,0 +1,16 @@
|
||||||
|
# --------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
# Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
|
# --------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
from msrest.serialization import Model
|
||||||
|
|
||||||
|
class GithubConnection(Model):
|
||||||
|
_attribute_map = {
|
||||||
|
'errorMessage': {'key': 'errorMessage', 'type': 'str'},
|
||||||
|
'url': {'key': 'url', 'type': 'str'},
|
||||||
|
}
|
||||||
|
|
||||||
|
def __init__(self, errorMessage=None, url=None):
|
||||||
|
self.errorMessage = errorMessage
|
||||||
|
self.url = url
|
|
@ -6,6 +6,9 @@
|
||||||
from subprocess import DEVNULL, STDOUT, check_call
|
from subprocess import DEVNULL, STDOUT, check_call
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from msrest.service_client import ServiceClient
|
||||||
|
from msrest import Configuration, Deserializer
|
||||||
|
from msrest.exceptions import HttpOperationError
|
||||||
import vsts.git.v4_1.models.git_repository_create_options as git_repository_create_options
|
import vsts.git.v4_1.models.git_repository_create_options as git_repository_create_options
|
||||||
|
|
||||||
from azure_devops_build_manager.base.base_manager import BaseManager
|
from azure_devops_build_manager.base.base_manager import BaseManager
|
||||||
|
@ -20,6 +23,11 @@ class RepositoryManager(BaseManager):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, organization_name="", project_name="", creds=None):
|
def __init__(self, organization_name="", project_name="", creds=None):
|
||||||
|
base_url = 'https://dev.azure.com'
|
||||||
|
self._config = Configuration(base_url=base_url)
|
||||||
|
self._client = ServiceClient(creds, self._config)
|
||||||
|
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
|
||||||
|
self._deserialize = Deserializer(client_models)
|
||||||
super(RepositoryManager, self).__init__(creds, organization_name=organization_name, project_name=project_name)
|
super(RepositoryManager, self).__init__(creds, organization_name=organization_name, project_name=project_name)
|
||||||
|
|
||||||
def create_repository(self, repository_name):
|
def create_repository(self, repository_name):
|
||||||
|
@ -33,19 +41,15 @@ class RepositoryManager(BaseManager):
|
||||||
return self._git_client.get_repositories(self._project_name)
|
return self._git_client.get_repositories(self._project_name)
|
||||||
|
|
||||||
def list_commits(self, repository_name):
|
def list_commits(self, repository_name):
|
||||||
|
"""List the commits for a given repository"""
|
||||||
project = self._get_project_by_name(self._project_name)
|
project = self._get_project_by_name(self._project_name)
|
||||||
repository = self._get_repository_by_name(project, repository_name)
|
repository = self._get_repository_by_name(project, repository_name)
|
||||||
return self._git_client.get_commits(repository.id, None, project=project.id)
|
return self._git_client.get_commits(repository.id, None, project=project.id)
|
||||||
|
|
||||||
|
|
||||||
def setup_repository(self, repository_name):
|
def setup_repository(self, repository_name):
|
||||||
"""This command sets up the repository locally - it initialises the git file and creates the initial push ect"""
|
"""This command sets up the repository locally - it initialises the git file and creates the initial push ect"""
|
||||||
if self._repository_exists():
|
if self._repository_exists():
|
||||||
message = """There is already an existing repository in this folder. If it is a github repository please
|
message = """There is already an existing repository in this folder."""
|
||||||
create an access token and then use the command 'az functionapp devops-build repository github
|
|
||||||
--token {OATH TOKEN}' If this is not an exisitng github or azure devops repository we are unable
|
|
||||||
to support a build through azure devops. Please either delete the reference to the repository in the current folder.
|
|
||||||
"""
|
|
||||||
succeeded = False
|
succeeded = False
|
||||||
else:
|
else:
|
||||||
origin_command = ["git", "remote", "add", "origin", "https://" + self._organization_name + \
|
origin_command = ["git", "remote", "add", "origin", "https://" + self._organization_name + \
|
||||||
|
@ -62,9 +66,42 @@ class RepositoryManager(BaseManager):
|
||||||
|
|
||||||
def _repository_exists(self):
|
def _repository_exists(self):
|
||||||
"""Helper to see if gitfile exists"""
|
"""Helper to see if gitfile exists"""
|
||||||
return True if os.path.exists('.git') else False
|
return bool(os.path.exists('.git'))
|
||||||
|
|
||||||
def _github(self):
|
def list_github_repositories(self):
|
||||||
"""
|
"""List github repositories if there are any from the current connection"""
|
||||||
TODO: setup the github integration to be able to do builds that are triggered by github!
|
project = self._get_project_by_name(self._project_name)
|
||||||
"""
|
service_endpoints = self._service_endpoint_client.get_service_endpoints(project.id)
|
||||||
|
github_endpoint = next((endpoint for endpoint in service_endpoints if endpoint.type == "github"), None)
|
||||||
|
return self._build_client.list_repositories(project.id, 'github', github_endpoint.id)
|
||||||
|
|
||||||
|
def create_github_connection(self):
|
||||||
|
"""Create a github connection endpoint that the user must go authenticate with"""
|
||||||
|
project = self._get_project_by_name(self._project_name)
|
||||||
|
|
||||||
|
url = '/' + self._organization_name + '/' + str(project.id) + \
|
||||||
|
'/_apis/connectedService/providers/github/authRequests'
|
||||||
|
|
||||||
|
query_paramters = {}
|
||||||
|
query_paramters['configurationId'] = '00000000-0000-0000-0000-000000000000'
|
||||||
|
query_paramters['scope'] = 'repo,read:user,user:email,admin:repo_hook'
|
||||||
|
|
||||||
|
#construct header parameters
|
||||||
|
header_paramters = {}
|
||||||
|
header_paramters['Accept'] = 'application/json;api-version=5.0;excludeUrls=true;' + \
|
||||||
|
'enumsAsNumbers=true;msDateFormat=true;noArrayWrap=true'
|
||||||
|
|
||||||
|
request = self._client.post(url, params=query_paramters)
|
||||||
|
response = self._client.send(request, headers=header_paramters)
|
||||||
|
|
||||||
|
# Handle Response
|
||||||
|
deserialized = None
|
||||||
|
if response.status_code not in [200]:
|
||||||
|
print("GET %s", request.url)
|
||||||
|
print("response: %s", response.status_code)
|
||||||
|
print(response.text)
|
||||||
|
raise HttpOperationError(self._deserialize, response)
|
||||||
|
else:
|
||||||
|
deserialized = self._deserialize('GithubConnection', response)
|
||||||
|
|
||||||
|
return deserialized
|
||||||
|
|
|
@ -21,7 +21,7 @@ class YamlManager(object):
|
||||||
self._language = language
|
self._language = language
|
||||||
self._app_type = app_type
|
self._app_type = app_type
|
||||||
|
|
||||||
def create_yaml(self, functionapp_name, subscription_name, storage_name, include_release=False):
|
def create_yaml(self, functionapp_name=None, subscription_name=None, storage_name=None, include_release=False, file_path=""):
|
||||||
"""Create the yaml to be able to create build in the azure-pipelines.yml file"""
|
"""Create the yaml to be able to create build in the azure-pipelines.yml file"""
|
||||||
if self._language == PYTHON:
|
if self._language == PYTHON:
|
||||||
dependencies = self._python_dependencies()
|
dependencies = self._python_dependencies()
|
||||||
|
@ -48,10 +48,14 @@ class YamlManager(object):
|
||||||
else:
|
else:
|
||||||
logging.warning("valid app type not found")
|
logging.warning("valid app type not found")
|
||||||
yaml = ""
|
yaml = ""
|
||||||
with open('azure-pipelines.yml', 'w') as f:
|
|
||||||
f.write(yaml)
|
|
||||||
|
|
||||||
|
|
||||||
|
# User can specify the file path
|
||||||
|
if file_path != "":
|
||||||
|
with open(file_path, 'w') as f:
|
||||||
|
f.write(yaml)
|
||||||
|
else:
|
||||||
|
with open('azure-pipelines.yml', 'w') as f:
|
||||||
|
f.write(yaml)
|
||||||
|
|
||||||
def _linux_consumption_yaml(self, dependencies, functionapp_name, storage_name, subscription_name, include_release):
|
def _linux_consumption_yaml(self, dependencies, functionapp_name, storage_name, subscription_name, include_release):
|
||||||
"""Helper to create the yaml for linux consumption"""
|
"""Helper to create the yaml for linux consumption"""
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
bin
|
||||||
|
obj
|
||||||
|
csx
|
||||||
|
.vs
|
||||||
|
edge
|
||||||
|
Publish
|
||||||
|
|
||||||
|
*.user
|
||||||
|
*.suo
|
||||||
|
*.cscfg
|
||||||
|
*.Cache
|
||||||
|
project.lock.json
|
||||||
|
|
||||||
|
/packages
|
||||||
|
/TestResults
|
||||||
|
|
||||||
|
/tools/NuGet.exe
|
||||||
|
/App_Data
|
||||||
|
/secrets
|
||||||
|
/data
|
||||||
|
.secrets
|
||||||
|
appsettings.json
|
||||||
|
local.settings.json
|
||||||
|
|
||||||
|
node_modules
|
||||||
|
|
||||||
|
# Local python packages
|
||||||
|
.python_packages/
|
||||||
|
|
||||||
|
# Python Environments
|
||||||
|
.env
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
|
@ -0,0 +1,20 @@
|
||||||
|
# Starter template for Azure functions build for
|
||||||
|
trigger:
|
||||||
|
- master
|
||||||
|
|
||||||
|
pool:
|
||||||
|
vmImage: ubuntu-16.04
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- script: pip3 install -r requirements.txt
|
||||||
|
- task: ArchiveFiles@2
|
||||||
|
displayName: "Archive files"
|
||||||
|
inputs:
|
||||||
|
rootFolderOrFile: "$(System.DefaultWorkingDirectory)"
|
||||||
|
includeRootFolder: false
|
||||||
|
tarCompression: none
|
||||||
|
archiveFile: "$(System.DefaultWorkingDirectory)/build$(Build.BuildId).zip"
|
||||||
|
- task: PublishBuildArtifacts@1
|
||||||
|
inputs:
|
||||||
|
PathtoPublish: '$(System.DefaultWorkingDirectory)/build$(Build.BuildId).zip'
|
||||||
|
name: 'drop'
|
|
@ -0,0 +1,24 @@
|
||||||
|
import logging
|
||||||
|
|
||||||
|
import azure.functions as func
|
||||||
|
|
||||||
|
|
||||||
|
def main(req: func.HttpRequest) -> func.HttpResponse:
|
||||||
|
logging.info('Python HTTP trigger function processed a request.')
|
||||||
|
|
||||||
|
name = req.params.get('name')
|
||||||
|
if not name:
|
||||||
|
try:
|
||||||
|
req_body = req.get_json()
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
name = req_body.get('name')
|
||||||
|
|
||||||
|
if name:
|
||||||
|
return func.HttpResponse(f"Hello {name}!")
|
||||||
|
else:
|
||||||
|
return func.HttpResponse(
|
||||||
|
"Please pass a name on the query string or in the request body",
|
||||||
|
status_code=400
|
||||||
|
)
|
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"scriptFile": "__init__.py",
|
||||||
|
"bindings": [
|
||||||
|
{
|
||||||
|
"authLevel": "anonymous",
|
||||||
|
"type": "httpTrigger",
|
||||||
|
"direction": "in",
|
||||||
|
"name": "req",
|
||||||
|
"methods": [
|
||||||
|
"get",
|
||||||
|
"post"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "http",
|
||||||
|
"direction": "out",
|
||||||
|
"name": "$return"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"name": "Azure"
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"version": "2.0"
|
||||||
|
}
|
|
@ -0,0 +1,212 @@
|
||||||
|
adal==1.2.0
|
||||||
|
antlr4-python3-runtime==4.7.2
|
||||||
|
applicationinsights==0.11.7
|
||||||
|
argcomplete==1.9.4
|
||||||
|
asn1crypto==0.24.0
|
||||||
|
astroid==2.1.0
|
||||||
|
azure==4.0.0
|
||||||
|
azure-applicationinsights==0.1.0
|
||||||
|
azure-batch==5.1.0
|
||||||
|
azure-cli==2.0.54
|
||||||
|
azure-cli-acr==2.1.11
|
||||||
|
azure-cli-acs==2.3.13
|
||||||
|
azure-cli-advisor==2.0.0
|
||||||
|
azure-cli-ams==0.3.1
|
||||||
|
azure-cli-appservice==0.2.10
|
||||||
|
azure-cli-backup==1.2.1
|
||||||
|
azure-cli-batch==3.4.1
|
||||||
|
azure-cli-batchai==0.4.5
|
||||||
|
azure-cli-billing==0.2.0
|
||||||
|
azure-cli-botservice==0.1.3
|
||||||
|
azure-cli-cdn==0.2.0
|
||||||
|
azure-cli-cloud==2.1.0
|
||||||
|
azure-cli-cognitiveservices==0.2.4
|
||||||
|
azure-cli-command-modules-nspkg==2.0.2
|
||||||
|
azure-cli-configure==2.0.19
|
||||||
|
azure-cli-consumption==0.4.1
|
||||||
|
azure-cli-container==0.3.10
|
||||||
|
azure-cli-core==2.0.54
|
||||||
|
azure-cli-cosmosdb==0.2.6
|
||||||
|
azure-cli-dla==0.2.3
|
||||||
|
azure-cli-dls==0.1.7
|
||||||
|
azure-cli-dms==0.1.1
|
||||||
|
azure-cli-eventgrid==0.2.0
|
||||||
|
azure-cli-eventhubs==0.3.2
|
||||||
|
azure-cli-extension==0.2.3
|
||||||
|
azure-cli-feedback==2.1.4
|
||||||
|
azure-cli-find==0.2.13
|
||||||
|
azure-cli-hdinsight==0.1.0
|
||||||
|
azure-cli-interactive==0.4.1
|
||||||
|
azure-cli-iot==0.3.4
|
||||||
|
azure-cli-iotcentral==0.1.5
|
||||||
|
azure-cli-keyvault==2.2.9
|
||||||
|
azure-cli-lab==0.1.4
|
||||||
|
azure-cli-maps==0.3.3
|
||||||
|
azure-cli-monitor==0.2.7
|
||||||
|
azure-cli-network==2.2.11
|
||||||
|
azure-cli-nspkg==3.0.3
|
||||||
|
azure-cli-policyinsights==0.1.0
|
||||||
|
azure-cli-profile==2.1.2
|
||||||
|
azure-cli-rdbms==0.3.5
|
||||||
|
azure-cli-redis==0.3.2
|
||||||
|
azure-cli-relay==0.1.2
|
||||||
|
azure-cli-reservations==0.4.1
|
||||||
|
azure-cli-resource==2.1.7
|
||||||
|
azure-cli-role==2.2.0
|
||||||
|
azure-cli-search==0.1.1
|
||||||
|
azure-cli-servicebus==0.3.2
|
||||||
|
azure-cli-servicefabric==0.1.10
|
||||||
|
azure-cli-signalr==1.0.0
|
||||||
|
azure-cli-sql==2.1.6
|
||||||
|
azure-cli-storage==2.2.7
|
||||||
|
azure-cli-telemetry==1.0.0
|
||||||
|
azure-cli-vm==2.2.11
|
||||||
|
azure-common==1.1.16
|
||||||
|
azure-cosmosdb-nspkg==2.0.2
|
||||||
|
azure-cosmosdb-table==1.0.5
|
||||||
|
azure-datalake-store==0.0.39
|
||||||
|
azure-eventgrid==1.2.0
|
||||||
|
azure-functions==1.0.0a5
|
||||||
|
azure-functions-worker==1.0.0a6
|
||||||
|
azure-graphrbac==0.53.0
|
||||||
|
azure-keyvault==1.1.0
|
||||||
|
azure-loganalytics==0.1.0
|
||||||
|
azure-mgmt==4.0.0
|
||||||
|
azure-mgmt-advisor==2.0.1
|
||||||
|
azure-mgmt-applicationinsights==0.1.1
|
||||||
|
azure-mgmt-authorization==0.50.0
|
||||||
|
azure-mgmt-batch==5.0.1
|
||||||
|
azure-mgmt-batchai==2.0.0
|
||||||
|
azure-mgmt-billing==0.2.0
|
||||||
|
azure-mgmt-botservice==0.1.0
|
||||||
|
azure-mgmt-cdn==3.0.0
|
||||||
|
azure-mgmt-cognitiveservices==3.0.0
|
||||||
|
azure-mgmt-commerce==1.0.1
|
||||||
|
azure-mgmt-compute==4.3.1
|
||||||
|
azure-mgmt-consumption==2.0.0
|
||||||
|
azure-mgmt-containerinstance==1.2.1
|
||||||
|
azure-mgmt-containerregistry==2.4.0
|
||||||
|
azure-mgmt-containerservice==4.2.2
|
||||||
|
azure-mgmt-cosmosdb==0.5.2
|
||||||
|
azure-mgmt-datafactory==0.6.0
|
||||||
|
azure-mgmt-datalake-analytics==0.2.0
|
||||||
|
azure-mgmt-datalake-nspkg==3.0.1
|
||||||
|
azure-mgmt-datalake-store==0.5.0
|
||||||
|
azure-mgmt-datamigration==0.1.0
|
||||||
|
azure-mgmt-devspaces==0.1.0
|
||||||
|
azure-mgmt-devtestlabs==2.2.0
|
||||||
|
azure-mgmt-dns==2.1.0
|
||||||
|
azure-mgmt-eventgrid==0.4.0
|
||||||
|
azure-mgmt-eventhub==2.2.0
|
||||||
|
azure-mgmt-hanaonazure==0.1.1
|
||||||
|
azure-mgmt-hdinsight==0.1.0
|
||||||
|
azure-mgmt-iotcentral==1.0.0
|
||||||
|
azure-mgmt-iothub==0.6.0
|
||||||
|
azure-mgmt-iothubprovisioningservices==0.2.0
|
||||||
|
azure-mgmt-keyvault==1.1.0
|
||||||
|
azure-mgmt-loganalytics==0.2.0
|
||||||
|
azure-mgmt-logic==3.0.0
|
||||||
|
azure-mgmt-machinelearningcompute==0.4.1
|
||||||
|
azure-mgmt-managementgroups==0.1.0
|
||||||
|
azure-mgmt-managementpartner==0.1.0
|
||||||
|
azure-mgmt-maps==0.1.0
|
||||||
|
azure-mgmt-marketplaceordering==0.1.0
|
||||||
|
azure-mgmt-media==1.0.1
|
||||||
|
azure-mgmt-monitor==0.5.2
|
||||||
|
azure-mgmt-msi==0.2.0
|
||||||
|
azure-mgmt-network==2.4.0
|
||||||
|
azure-mgmt-notificationhubs==2.0.0
|
||||||
|
azure-mgmt-nspkg==3.0.2
|
||||||
|
azure-mgmt-policyinsights==0.1.0
|
||||||
|
azure-mgmt-powerbiembedded==2.0.0
|
||||||
|
azure-mgmt-rdbms==1.5.0
|
||||||
|
azure-mgmt-recoveryservices==0.1.0
|
||||||
|
azure-mgmt-recoveryservicesbackup==0.1.1
|
||||||
|
azure-mgmt-redis==5.0.0
|
||||||
|
azure-mgmt-relay==0.1.0
|
||||||
|
azure-mgmt-reservations==0.3.1
|
||||||
|
azure-mgmt-resource==2.0.0
|
||||||
|
azure-mgmt-scheduler==2.0.0
|
||||||
|
azure-mgmt-search==2.0.0
|
||||||
|
azure-mgmt-servicebus==0.5.3
|
||||||
|
azure-mgmt-servicefabric==0.2.0
|
||||||
|
azure-mgmt-signalr==0.1.1
|
||||||
|
azure-mgmt-sql==0.9.1
|
||||||
|
azure-mgmt-storage==3.1.0
|
||||||
|
azure-mgmt-subscription==0.2.0
|
||||||
|
azure-mgmt-trafficmanager==0.50.0
|
||||||
|
azure-mgmt-web==0.40.0
|
||||||
|
azure-multiapi-storage==0.2.2
|
||||||
|
azure-nspkg==3.0.2
|
||||||
|
azure-servicebus==0.21.1
|
||||||
|
azure-servicefabric==6.3.0.0
|
||||||
|
azure-servicemanagement-legacy==0.20.6
|
||||||
|
azure-storage-blob==1.3.1
|
||||||
|
azure-storage-common==1.4.0
|
||||||
|
azure-storage-file==1.4.0
|
||||||
|
azure-storage-nspkg==3.1.0
|
||||||
|
azure-storage-queue==1.4.0
|
||||||
|
bcrypt==3.1.5
|
||||||
|
certifi==2018.11.29
|
||||||
|
cffi==1.11.5
|
||||||
|
chardet==3.0.4
|
||||||
|
colorama==0.4.1
|
||||||
|
cryptography==2.4.2
|
||||||
|
Deprecated==1.2.4
|
||||||
|
futures==3.1.1
|
||||||
|
github3.py==1.2.0
|
||||||
|
grpcio==1.14.2
|
||||||
|
grpcio-tools==1.14.2
|
||||||
|
humanfriendly==4.17
|
||||||
|
idna==2.8
|
||||||
|
ipaddress==1.0.22
|
||||||
|
isodate==0.6.0
|
||||||
|
isort==4.3.4
|
||||||
|
Jinja2==2.10
|
||||||
|
jmespath==0.9.3
|
||||||
|
jwcrypto==0.6.0
|
||||||
|
knack==0.5.1
|
||||||
|
lazy-object-proxy==1.3.1
|
||||||
|
MarkupSafe==1.1.0
|
||||||
|
mccabe==0.6.1
|
||||||
|
mock==2.0.0
|
||||||
|
msrest==0.6.2
|
||||||
|
msrestazure==0.6.0
|
||||||
|
oauthlib==2.1.0
|
||||||
|
paramiko==2.4.2
|
||||||
|
pbr==5.1.1
|
||||||
|
portalocker==1.2.1
|
||||||
|
prompt-toolkit==1.0.15
|
||||||
|
protobuf==3.6.1
|
||||||
|
pyasn1==0.4.5
|
||||||
|
pycparser==2.19
|
||||||
|
pydocumentdb==2.3.3
|
||||||
|
PyGithub==1.43.4
|
||||||
|
Pygments==2.3.1
|
||||||
|
PyJWT==1.7.1
|
||||||
|
pylint==2.2.2
|
||||||
|
PyNaCl==1.3.0
|
||||||
|
pyOpenSSL==18.0.0
|
||||||
|
pypiwin32==223
|
||||||
|
pyreadline==2.1
|
||||||
|
python-dateutil==2.7.5
|
||||||
|
pytz==2018.9
|
||||||
|
pywin32==224
|
||||||
|
PyYAML==3.13
|
||||||
|
requests==2.21.0
|
||||||
|
requests-oauthlib==1.0.0
|
||||||
|
scp==0.13.0
|
||||||
|
six==1.12.0
|
||||||
|
sshtunnel==0.1.4
|
||||||
|
tabulate==0.8.2
|
||||||
|
typed-ast==1.1.1
|
||||||
|
uritemplate==3.0.0
|
||||||
|
urllib3==1.24.1
|
||||||
|
vsts==0.1.22
|
||||||
|
vsts-cd-manager==1.0.2
|
||||||
|
wcwidth==0.1.7
|
||||||
|
websocket-client==0.54.0
|
||||||
|
Whoosh==2.7.4
|
||||||
|
wrapt==1.10.11
|
||||||
|
xmltodict==0.11.0
|
||||||
|
|
|
@ -178,7 +178,7 @@ pyreadline==2.1
|
||||||
python-dateutil==2.7.5
|
python-dateutil==2.7.5
|
||||||
pytz==2018.9
|
pytz==2018.9
|
||||||
pywin32==224
|
pywin32==224
|
||||||
PyYAML==3.13
|
pyyaml>=4.2b1
|
||||||
requests==2.21.0
|
requests==2.21.0
|
||||||
requests-oauthlib==1.0.0
|
requests-oauthlib==1.0.0
|
||||||
scp==0.13.0
|
scp==0.13.0
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
call rmdir /s /q python_test_application
|
||||||
|
call func init python_test_application --worker-runtime python
|
||||||
|
call cd python_test_application
|
||||||
|
call func new --name home --template "HTTP Trigger"
|
||||||
|
call cd ..
|
||||||
|
call python -m tests.suite
|
||||||
|
call rmdir /s /q python_test_application
|
|
@ -0,0 +1,4 @@
|
||||||
|
# --------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
# Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
|
# --------------------------------------------------------------------------------------------
|
|
@ -5,5 +5,28 @@
|
||||||
|
|
||||||
"""This file contains the configs needed for the tests"""
|
"""This file contains the configs needed for the tests"""
|
||||||
|
|
||||||
ORGANIZATION_NAME = 't-oldolk'
|
# You need to fill in the variables with names of the resources you already have
|
||||||
PROJECT_NAME = 'test'
|
# When you are finished setting the configs then you can run test.cmd
|
||||||
|
|
||||||
|
# The create devops objects setting sets whether the test will run create commands. The default is false
|
||||||
|
CREATE_DEVOPS_OBJECTS = False
|
||||||
|
|
||||||
|
# Specify the name of your already created devops objects
|
||||||
|
ORGANIZATION_NAME = 'colbys-donut-pizza'
|
||||||
|
PROJECT_NAME = 'donut-pizza-2'
|
||||||
|
REPOSITORY_NAME = 'donut-pizza-2'
|
||||||
|
SERVICE_ENDPOINT_NAME = ORGANIZATION_NAME + PROJECT_NAME
|
||||||
|
GITHUB_REPOSITORY_NAME = 'python_simple_functionapp_tester'
|
||||||
|
|
||||||
|
BUILD_DEFINITION_NAME_GIT = 'github-test-3'
|
||||||
|
BUILD_DEFINITION_NAME = 'normal-test-1'
|
||||||
|
RELEASE_DEFINITION_NAME = 'release blah'
|
||||||
|
|
||||||
|
# Do not change this from default.
|
||||||
|
POOL_NAME = 'Default'
|
||||||
|
|
||||||
|
# Specify the details of your azure functions resource
|
||||||
|
FUNCTIONAPP_NAME = 'dolk-devops-python'
|
||||||
|
SUBSCRIPTION_NAME = 'dolk-devops-python'
|
||||||
|
STORAGE_NAME = 'dolkdevops-9283'
|
||||||
|
RESOURCE_GROUP_NAME = 'dolk-devops-python'
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
# --------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
# Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
|
# --------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
"""This file contains the configs needed for the tests"""
|
||||||
|
|
||||||
|
# You need to fill in the variables with names of the resources you already have
|
||||||
|
# When you are finished setting the configs then you can run test.cmd
|
||||||
|
|
||||||
|
# The create devops objects setting sets whether the test will run create commands. The default is false.
|
||||||
|
# You need to be careful as
|
||||||
|
CREATE_DEVOPS_OBJECTS = False
|
||||||
|
|
||||||
|
# If the create devops is false you only need to specify the following:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Specify the name of your already created devops objects
|
||||||
|
ORGANIZATION_NAME = '{organization name}'
|
||||||
|
PROJECT_NAME = '{project name}'
|
||||||
|
REPOSITORY_NAME = '{repository name within the project}'
|
||||||
|
SERVICE_ENDPOINT_NAME = ORGANIZATION_NAME + PROJECT_NAME
|
||||||
|
GITHUB_REPOSITORY_NAME = '{github repository name }' # leave this as if if not running the github tests
|
||||||
|
|
||||||
|
BUILD_DEFINITION_NAME_GIT = '{build definition name for github test}'
|
||||||
|
BUILD_DEFINITION_NAME = '{build definition name}'
|
||||||
|
RELEASE_DEFINITION_NAME = '{release definition name}'
|
||||||
|
|
||||||
|
# Do not change this from default.
|
||||||
|
POOL_NAME = 'Default'
|
||||||
|
|
||||||
|
# Specify the details of your azure functions resource
|
||||||
|
FUNCTIONAPP_NAME = '{functionapp name}'
|
||||||
|
SUBSCRIPTION_NAME = '{subscription name'
|
||||||
|
STORAGE_NAME = '{storage name}'
|
||||||
|
RESOURCE_GROUP_NAME = '{resource group name}'
|
|
@ -0,0 +1,15 @@
|
||||||
|
# --------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
# Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
|
# --------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
"""This file contains the some helpers needed for the tests"""
|
||||||
|
|
||||||
|
from azure.cli.core import get_default_cli
|
||||||
|
from azure.cli.core._profile import Profile
|
||||||
|
|
||||||
|
def get_credentials():
|
||||||
|
cli_ctx = get_default_cli()
|
||||||
|
profile = Profile(cli_ctx=cli_ctx)
|
||||||
|
creds, _, _ = profile.get_login_credentials(subscription_id=None)
|
||||||
|
return creds
|
|
@ -0,0 +1,61 @@
|
||||||
|
import unittest
|
||||||
|
from .test_artifact_manager import TestArtifactManager
|
||||||
|
from .test_builder_manager import TestBuilderManager
|
||||||
|
from .test_extension_manager import TestExtensionManager
|
||||||
|
from .test_organization_manager import TestOrganizationManager
|
||||||
|
from .test_pool_manager import TestPoolManager
|
||||||
|
from .test_project_manager import TestProjectManager
|
||||||
|
from .test_release_manager import TestReleaseManager
|
||||||
|
from .test_repository_manager import TestRepositoryManager
|
||||||
|
from .test_service_endpoint_manager import TestServiceEndpointManager
|
||||||
|
from .test_yaml_manager import TestYamlManager
|
||||||
|
|
||||||
|
# TODO : Github integration test suite
|
||||||
|
|
||||||
|
def suite():
|
||||||
|
suite = unittest.TestSuite()
|
||||||
|
# Test the relevant elements of the organization manager
|
||||||
|
suite.addTest(TestOrganizationManager('test_invalid_organization_name_characters'))
|
||||||
|
suite.addTest(TestOrganizationManager('test_invalid_organization_name_already_exists'))
|
||||||
|
suite.addTest(TestOrganizationManager('test_valid_organization_name'))
|
||||||
|
suite.addTest(TestOrganizationManager('test_regions'))
|
||||||
|
suite.addTest(TestOrganizationManager('test_create_organization'))
|
||||||
|
suite.addTest(TestOrganizationManager('test_list_organizations'))
|
||||||
|
|
||||||
|
# Test the relevant elements of the project manager
|
||||||
|
suite.addTest(TestProjectManager('test_list_projects'))
|
||||||
|
suite.addTest(TestProjectManager('test_create_project'))
|
||||||
|
|
||||||
|
# Test the yaml manager
|
||||||
|
suite.addTest(TestYamlManager('test_create_yaml'))
|
||||||
|
|
||||||
|
# Test the repository manager
|
||||||
|
suite.addTest(TestRepositoryManager('test_list_commits'))
|
||||||
|
suite.addTest(TestRepositoryManager('test_list_repositories'))
|
||||||
|
|
||||||
|
# Test the service endpoint
|
||||||
|
suite.addTest(TestServiceEndpointManager('test_create_service_endpoint'))
|
||||||
|
suite.addTest(TestServiceEndpointManager('test_list_service_endpoint'))
|
||||||
|
|
||||||
|
# Test the extensions
|
||||||
|
suite.addTest(TestExtensionManager('test_create_extension'))
|
||||||
|
suite.addTest(TestExtensionManager('test_list_extensions'))
|
||||||
|
|
||||||
|
# Test the builder
|
||||||
|
suite.addTest(TestBuilderManager('test_list_definitions'))
|
||||||
|
suite.addTest(TestBuilderManager('test_list_builds'))
|
||||||
|
suite.addTest(TestBuilderManager('test_create_definition_and_build'))
|
||||||
|
|
||||||
|
# Test the releaser
|
||||||
|
suite.addTest(TestReleaseManager('test_list_release_definitions'))
|
||||||
|
suite.addTest(TestReleaseManager('test_list_releases'))
|
||||||
|
suite.addTest(TestReleaseManager('test_basic_release'))
|
||||||
|
|
||||||
|
suite.addTest(TestArtifactManager('test_list_artifacts'))
|
||||||
|
suite.addTest(TestPoolManager('test_list_pools'))
|
||||||
|
|
||||||
|
return suite
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
runner = unittest.TextTestRunner()
|
||||||
|
runner.run(suite())
|
|
@ -1,19 +1,27 @@
|
||||||
|
# --------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
# Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
|
# --------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
from azure.cli.core import get_default_cli
|
|
||||||
from azure.cli.core._profile import Profile
|
import vsts
|
||||||
|
from vsts.build.v4_1.models.build_artifact import BuildArtifact
|
||||||
|
import azure_devops_build_manager
|
||||||
from azure_devops_build_manager.artifact.artifact_manager import ArtifactManager
|
from azure_devops_build_manager.artifact.artifact_manager import ArtifactManager
|
||||||
from ._config import ORGANIZATION_NAME, PROJECT_NAME
|
from ._config import ORGANIZATION_NAME, PROJECT_NAME
|
||||||
|
from ._helpers import get_credentials
|
||||||
|
|
||||||
class TestArtifactManager(unittest.TestCase):
|
class TestArtifactManager(unittest.TestCase):
|
||||||
|
|
||||||
def test_list_extensions(self):
|
def test_list_artifacts(self):
|
||||||
cli_ctx = get_default_cli()
|
"""This test tests the functionality of listing artifacts. It requires there to be artifacts to list in the project"""
|
||||||
profile = Profile(cli_ctx=cli_ctx)
|
creds = get_credentials()
|
||||||
creds, _, _ = profile.get_login_credentials(subscription_id=None)
|
organization_name = ORGANIZATION_NAME
|
||||||
organization_name = "function-deployments-releases"
|
project_name = PROJECT_NAME
|
||||||
project_name = "blah"
|
|
||||||
artifact_manager = ArtifactManager(organization_name=organization_name, project_name=project_name, creds=creds)
|
artifact_manager = ArtifactManager(organization_name=organization_name, project_name=project_name, creds=creds)
|
||||||
self.assertTrue(type(artifact_manager.list_artifacts("1")) == list)
|
artifacts = artifact_manager.list_artifacts("1")
|
||||||
|
if artifacts:
|
||||||
if __name__ == '__main__':
|
# If the user is using the devops build manager to make builds there should only be one artifact
|
||||||
unittest.main()
|
# called drop as a result of running the builder commands.
|
||||||
|
self.assertEqual(artifacts[0].name, 'drop')
|
||||||
|
|
|
@ -1,16 +1,43 @@
|
||||||
|
# --------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
# Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
|
# --------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
from azure.cli.core import get_default_cli
|
|
||||||
from azure.cli.core._profile import Profile
|
|
||||||
from azure_devops_build_manager.builder.builder_manager import BuilderManager
|
from azure_devops_build_manager.builder.builder_manager import BuilderManager
|
||||||
|
from ._config import CREATE_DEVOPS_OBJECTS, ORGANIZATION_NAME, PROJECT_NAME, REPOSITORY_NAME, BUILD_DEFINITION_NAME, BUILD_DEFINITION_NAME_GIT, POOL_NAME
|
||||||
|
from ._helpers import get_credentials
|
||||||
|
|
||||||
class TestBuilderManager(unittest.TestCase):
|
class TestBuilderManager(unittest.TestCase):
|
||||||
|
|
||||||
def test_list_extensions(self):
|
def test_list_definitions(self):
|
||||||
cli_ctx = get_default_cli()
|
creds = get_credentials()
|
||||||
profile = Profile(cli_ctx=cli_ctx)
|
builder_manager = BuilderManager(organization_name=ORGANIZATION_NAME, project_name=PROJECT_NAME, repository_name=REPOSITORY_NAME, creds=creds)
|
||||||
creds, _, _ = profile.get_login_credentials(subscription_id=None)
|
builds = builder_manager.list_builds()
|
||||||
|
|
||||||
|
def test_list_builds(self):
|
||||||
|
creds = get_credentials()
|
||||||
|
builder_manager = BuilderManager(organization_name=ORGANIZATION_NAME, project_name=PROJECT_NAME, repository_name=REPOSITORY_NAME, creds=creds)
|
||||||
|
definitions = builder_manager.list_definitions()
|
||||||
|
|
||||||
|
@unittest.skipIf(CREATE_DEVOPS_OBJECTS == False,
|
||||||
|
"skipping - set CREATE_DEVOPS_OBJECTS to True if you don't want to skip creates")
|
||||||
|
def test_create_definition_and_build(self):
|
||||||
|
creds = get_credentials()
|
||||||
|
builder_manager = BuilderManager(organization_name=ORGANIZATION_NAME, project_name=PROJECT_NAME, repository_name=REPOSITORY_NAME, creds=creds)
|
||||||
|
definition = builder_manager.create_definition(BUILD_DEFINITION_NAME, POOL_NAME)
|
||||||
|
self.assertEqual(definition.name, BUILD_DEFINITION_NAME)
|
||||||
|
self.assertEqual(definition.process['yamlFilename'], 'azure-pipelines.yml')
|
||||||
|
build = builder_manager.create_build(BUILD_DEFINITION_NAME, POOL_NAME)
|
||||||
|
|
||||||
|
@unittest.skipIf(CREATE_DEVOPS_OBJECTS == False,
|
||||||
|
"skipping - set CREATE_DEVOPS_OBJECTS to True if you don't want to skip creates")
|
||||||
|
def test_github_create_definition_and_build(self):
|
||||||
|
creds = get_credentials()
|
||||||
|
builder_manager = BuilderManager(organization_name=ORGANIZATION_NAME, project_name=PROJECT_NAME, repository_name=REPOSITORY_NAME, creds=creds)
|
||||||
|
definition = builder_manager.create_definition(BUILD_DEFINITION_NAME_GIT, POOL_NAME, github=True)
|
||||||
|
self.assertEqual(definition.name, BUILD_DEFINITION_NAME_GIT)
|
||||||
|
build = builder_manager.create_build(BUILD_DEFINITION_NAME_GIT, POOL_NAME)
|
||||||
|
|
||||||
#TODO(oliver): test this - not sure how
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
|
@ -1,28 +1,34 @@
|
||||||
|
# --------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
# Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
|
# --------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import unittest, string, random
|
import unittest, string, random
|
||||||
from azure.cli.core import get_default_cli
|
from azure.cli.core import get_default_cli
|
||||||
from azure.cli.core._profile import Profile
|
from azure.cli.core._profile import Profile
|
||||||
from azure_devops_build_manager.extension.extension_manager import ExtensionManager
|
from azure_devops_build_manager.extension.extension_manager import ExtensionManager
|
||||||
|
from ._config import CREATE_DEVOPS_OBJECTS, ORGANIZATION_NAME, PROJECT_NAME
|
||||||
|
from ._helpers import get_credentials
|
||||||
|
|
||||||
class TestExtensionManager(unittest.TestCase):
|
class TestExtensionManager(unittest.TestCase):
|
||||||
|
|
||||||
def test_list_extensions(self):
|
def test_list_extensions(self):
|
||||||
cli_ctx = get_default_cli()
|
creds = get_credentials()
|
||||||
profile = Profile(cli_ctx=cli_ctx)
|
extension_manager = ExtensionManager(organization_name=ORGANIZATION_NAME, creds=creds)
|
||||||
creds, _, _ = profile.get_login_credentials(subscription_id=None)
|
|
||||||
extension_manager = ExtensionManager(organization_name="t-oldolk", creds=creds)
|
|
||||||
extensions = extension_manager.list_extensions()
|
extensions = extension_manager.list_extensions()
|
||||||
self.assertTrue(type(extensions) == list)
|
self.assertTrue(type(extensions) == list)
|
||||||
|
|
||||||
|
@unittest.skipIf(CREATE_DEVOPS_OBJECTS == False,
|
||||||
|
"skipping - set CREATE_DEVOPS_OBJECTS to True if you don't want to skip creates")
|
||||||
def test_create_extension(self):
|
def test_create_extension(self):
|
||||||
cli_ctx = get_default_cli()
|
creds = get_credentials()
|
||||||
profile = Profile(cli_ctx=cli_ctx)
|
extension_manager = ExtensionManager(organization_name=ORGANIZATION_NAME, creds=creds)
|
||||||
creds, _, _ = profile.get_login_credentials(subscription_id=None)
|
|
||||||
extension_manager = ExtensionManager(organization_name="t-oldolk", creds=creds)
|
|
||||||
new_extension = extension_manager.create_extension('AzureAppServiceSetAppSettings', 'hboelman')
|
new_extension = extension_manager.create_extension('AzureAppServiceSetAppSettings', 'hboelman')
|
||||||
self.assertTrue(new_extension.publisher_id == 'hboelman')
|
self.assertTrue(new_extension.publisher_id == 'hboelman')
|
||||||
self.assertTrue(new_extension.extension_id == 'AzureAppServiceSetAppSettings')
|
self.assertTrue(new_extension.extension_id == 'AzureAppServiceSetAppSettings')
|
||||||
|
new_extension = extension_manager.create_extension('PascalNaber-Xpirit-CreateSasToken', 'pascalnaber')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
|
@ -1,3 +1,8 @@
|
||||||
|
# --------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
# Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
|
# --------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import unittest, string, random
|
import unittest, string, random
|
||||||
|
@ -5,6 +10,8 @@ from azure.cli.core import get_default_cli
|
||||||
from azure.cli.core._profile import Profile
|
from azure.cli.core._profile import Profile
|
||||||
from azure_devops_build_manager.organization.organization_manager import OrganizationManager
|
from azure_devops_build_manager.organization.organization_manager import OrganizationManager
|
||||||
from azure_devops_build_manager.user.user_manager import UserManager
|
from azure_devops_build_manager.user.user_manager import UserManager
|
||||||
|
from ._config import CREATE_DEVOPS_OBJECTS, ORGANIZATION_NAME
|
||||||
|
from ._helpers import get_credentials
|
||||||
|
|
||||||
class TestOrganizationManager(unittest.TestCase):
|
class TestOrganizationManager(unittest.TestCase):
|
||||||
|
|
||||||
|
@ -12,88 +19,57 @@ class TestOrganizationManager(unittest.TestCase):
|
||||||
return ''.join(random.choice(chars) for _ in range(size))
|
return ''.join(random.choice(chars) for _ in range(size))
|
||||||
|
|
||||||
def test_invalid_organization_name_characters(self):
|
def test_invalid_organization_name_characters(self):
|
||||||
cli_ctx = get_default_cli()
|
creds = get_credentials()
|
||||||
profile = Profile(cli_ctx=cli_ctx)
|
|
||||||
creds, _, _ = profile.get_login_credentials(subscription_id=None)
|
|
||||||
organization_manager = OrganizationManager(base_url='https://app.vssps.visualstudio.com', creds=creds)
|
organization_manager = OrganizationManager(base_url='https://app.vssps.visualstudio.com', creds=creds)
|
||||||
validation = organization_manager.validate_organization_name('hello_123##')
|
validation = organization_manager.validate_organization_name('hello_123##')
|
||||||
self.assertFalse(validation.valid)
|
self.assertFalse(validation.valid)
|
||||||
|
|
||||||
organization_manager.close_connection()
|
organization_manager.close_connection()
|
||||||
|
|
||||||
|
|
||||||
def test_invalid_organization_name_already_exists(self):
|
def test_invalid_organization_name_already_exists(self):
|
||||||
cli_ctx = get_default_cli()
|
creds = get_credentials()
|
||||||
profile = Profile(cli_ctx=cli_ctx)
|
|
||||||
creds, _, _ = profile.get_login_credentials(subscription_id=None)
|
|
||||||
|
|
||||||
organization_manager = OrganizationManager(base_url='https://app.vssps.visualstudio.com', creds=creds)
|
organization_manager = OrganizationManager(base_url='https://app.vssps.visualstudio.com', creds=creds)
|
||||||
validation = organization_manager.validate_organization_name('hello')
|
validation = organization_manager.validate_organization_name('hello')
|
||||||
self.assertFalse(validation.valid)
|
self.assertFalse(validation.valid)
|
||||||
|
|
||||||
organization_manager.close_connection()
|
organization_manager.close_connection()
|
||||||
|
|
||||||
|
|
||||||
def test_valid_organization_name(self):
|
def test_valid_organization_name(self):
|
||||||
#construct the cli_ctx to auth
|
creds = get_credentials()
|
||||||
cli_ctx = get_default_cli()
|
|
||||||
profile = Profile(cli_ctx=cli_ctx)
|
|
||||||
creds, _, _ = profile.get_login_credentials(subscription_id=None)
|
|
||||||
|
|
||||||
organization_manager = OrganizationManager(base_url='https://app.vssps.visualstudio.com', creds=creds)
|
organization_manager = OrganizationManager(base_url='https://app.vssps.visualstudio.com', creds=creds)
|
||||||
validation = organization_manager.validate_organization_name('iamatruelykeenbeans')
|
validation = organization_manager.validate_organization_name('iamatruelykeenbeans')
|
||||||
self.assertTrue(validation.valid)
|
self.assertTrue(validation.valid)
|
||||||
|
|
||||||
organization_manager.close_connection()
|
organization_manager.close_connection()
|
||||||
|
|
||||||
def test_regions(self):
|
def test_regions(self):
|
||||||
#construct the cli_ctx to auth
|
creds = get_credentials()
|
||||||
cli_ctx = get_default_cli()
|
|
||||||
profile = Profile(cli_ctx=cli_ctx)
|
|
||||||
creds, _, _ = profile.get_login_credentials(subscription_id=None)
|
|
||||||
|
|
||||||
organization_manager = OrganizationManager(base_url='https://app.vssps.visualstudio.com', creds=creds)
|
organization_manager = OrganizationManager(base_url='https://app.vssps.visualstudio.com', creds=creds)
|
||||||
regions = organization_manager.list_regions()
|
regions = organization_manager.list_regions()
|
||||||
|
self.assertEqual(regions.count, len(regions.value))
|
||||||
self.assertEqual(regions.count, 7)
|
|
||||||
|
|
||||||
organization_manager.close_connection()
|
organization_manager.close_connection()
|
||||||
|
|
||||||
@unittest.skip("skipping - remove this if you want to create organizations")
|
@unittest.skipIf(CREATE_DEVOPS_OBJECTS == False,
|
||||||
|
"skipping - set CREATE_DEVOPS_OBJECTS to True if you don't want to skip creates")
|
||||||
def test_create_organization(self):
|
def test_create_organization(self):
|
||||||
#construct the cli_ctx to auth
|
creds = get_credentials()
|
||||||
cli_ctx = get_default_cli()
|
|
||||||
profile = Profile(cli_ctx=cli_ctx)
|
|
||||||
creds, _, _ = profile.get_login_credentials(subscription_id=None)
|
|
||||||
|
|
||||||
name = self.id_generator()
|
|
||||||
|
|
||||||
organization_manager = OrganizationManager(base_url='https://app.vssps.visualstudio.com', creds=creds, create_organization_url='https://app.vsaex.visualstudio.com')
|
organization_manager = OrganizationManager(base_url='https://app.vssps.visualstudio.com', creds=creds, create_organization_url='https://app.vsaex.visualstudio.com')
|
||||||
regions = organization_manager.get_regions()
|
regions = organization_manager.get_regions()
|
||||||
|
organization_manager.create_organization(regions.value[0].regionCode, ORGANIZATION_NAME)
|
||||||
organization_manager.create_organization(regions.value[0].regionCode, name)
|
|
||||||
|
|
||||||
#since we have created the organization the name is taken
|
#since we have created the organization the name is taken
|
||||||
validation = organization_manager.validate_organization_name(name)
|
validation = organization_manager.validate_organization_name(ORGANIZATION_NAME)
|
||||||
self.assertFalse(validation.valid)
|
self.assertFalse(validation.valid)
|
||||||
|
|
||||||
organization_manager.close_connection()
|
organization_manager.close_connection()
|
||||||
|
|
||||||
def test_get_organization(self):
|
def test_list_organizations(self):
|
||||||
cli_ctx = get_default_cli()
|
creds = get_credentials()
|
||||||
profile = Profile(cli_ctx=cli_ctx)
|
|
||||||
creds, _, _ = profile.get_login_credentials(subscription_id=None)
|
|
||||||
|
|
||||||
organization_manager = OrganizationManager(creds=creds)
|
organization_manager = OrganizationManager(creds=creds)
|
||||||
user_manager = UserManager(creds=creds)
|
user_manager = UserManager(creds=creds)
|
||||||
|
|
||||||
userid = user_manager.get_user_id()
|
userid = user_manager.get_user_id()
|
||||||
|
|
||||||
self.assertRegex(userid.id, r"^[0-9A-Za-z-]+$")
|
self.assertRegex(userid.id, r"^[0-9A-Za-z-]+$")
|
||||||
|
|
||||||
organizations = organization_manager.list_organizations(userid.id)
|
organizations = organization_manager.list_organizations(userid.id)
|
||||||
print(organizations.value[0])
|
|
||||||
self.assertTrue(len(organizations.value), organizations.count)
|
self.assertTrue(len(organizations.value), organizations.count)
|
||||||
|
found_organization = next((organization for organization in organizations.value if organization.accountName == ORGANIZATION_NAME), None)
|
||||||
|
self.assertTrue(found_organization != None)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
|
@ -1,15 +1,20 @@
|
||||||
|
# --------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
# Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
|
# --------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
from azure.cli.core import get_default_cli
|
from azure.cli.core import get_default_cli
|
||||||
from azure.cli.core._profile import Profile
|
from azure.cli.core._profile import Profile
|
||||||
from azure_devops_build_manager.pool.pool_manager import PoolManager
|
from azure_devops_build_manager.pool.pool_manager import PoolManager
|
||||||
|
from ._config import CREATE_DEVOPS_OBJECTS, ORGANIZATION_NAME, PROJECT_NAME
|
||||||
|
from ._helpers import get_credentials
|
||||||
|
|
||||||
class TestPoolManager(unittest.TestCase):
|
class TestPoolManager(unittest.TestCase):
|
||||||
|
|
||||||
def test_list_pools(self):
|
def test_list_pools(self):
|
||||||
cli_ctx = get_default_cli()
|
creds = get_credentials()
|
||||||
profile = Profile(cli_ctx=cli_ctx)
|
pool_manager = PoolManager(organization_name=ORGANIZATION_NAME, project_name=PROJECT_NAME, creds=creds)
|
||||||
creds, _, _ = profile.get_login_credentials(subscription_id=None)
|
|
||||||
pool_manager = PoolManager(organization_name="t-oldolk", project_name="demo", creds=creds)
|
|
||||||
pools = (pool_manager.list_pools())
|
pools = (pool_manager.list_pools())
|
||||||
self.assertTrue(len(pools.value), pools.count)
|
self.assertTrue(len(pools.value), pools.count)
|
||||||
pool_manager.close_connection()
|
pool_manager.close_connection()
|
||||||
|
|
|
@ -1,29 +1,31 @@
|
||||||
|
# --------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
# Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
|
# --------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import unittest, string, random
|
import unittest, string, random
|
||||||
from azure.cli.core import get_default_cli
|
from azure.cli.core import get_default_cli
|
||||||
from azure.cli.core._profile import Profile
|
from azure.cli.core._profile import Profile
|
||||||
from azure_devops_build_manager.project.project_manager import ProjectManager
|
from azure_devops_build_manager.project.project_manager import ProjectManager
|
||||||
|
from ._config import CREATE_DEVOPS_OBJECTS, ORGANIZATION_NAME, PROJECT_NAME
|
||||||
|
from ._helpers import get_credentials
|
||||||
|
|
||||||
class TestProjectManager(unittest.TestCase):
|
class TestProjectManager(unittest.TestCase):
|
||||||
|
|
||||||
def test_get_projects(self):
|
def test_list_projects(self):
|
||||||
cli_ctx = get_default_cli()
|
creds = get_credentials()
|
||||||
profile = Profile(cli_ctx=cli_ctx)
|
project_manager = ProjectManager(organization_name=ORGANIZATION_NAME, creds=creds)
|
||||||
creds, _, _ = profile.get_login_credentials(subscription_id=None)
|
projects = project_manager.list_projects()
|
||||||
project_manager = ProjectManager(organization_name="t-oldolk", creds=creds)
|
self.assertEqual(projects.count, len(projects.value))
|
||||||
projects = project_manager.get_existing_projects()
|
|
||||||
|
|
||||||
self.assertTrue(hasattr(projects, 'value'))
|
@unittest.skipIf(CREATE_DEVOPS_OBJECTS == False,
|
||||||
self.assertTrue(hasattr(projects, 'count'))
|
"skipping - set CREATE_DEVOPS_OBJECTS to True if you don't want to skip creates")
|
||||||
|
|
||||||
def test_create_project(self):
|
def test_create_project(self):
|
||||||
cli_ctx = get_default_cli()
|
creds = get_credentials()
|
||||||
profile = Profile(cli_ctx=cli_ctx)
|
project_manager = ProjectManager(organization_name=ORGANIZATION_NAME, creds=creds)
|
||||||
creds, _, _ = profile.get_login_credentials(subscription_id=None)
|
p = project_manager.create_project(PROJECT_NAME)
|
||||||
project_manager = ProjectManager(organization_name="az-cli-tests", creds=creds)
|
|
||||||
|
|
||||||
p = project_manager.create_project("car2")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
# --------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
# Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
|
# --------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import unittest, string, random
|
import unittest, string, random
|
||||||
|
@ -5,23 +10,30 @@ from azure.cli.core import get_default_cli
|
||||||
from azure.cli.core._profile import Profile
|
from azure.cli.core._profile import Profile
|
||||||
from azure_devops_build_manager.release.release_manager import ReleaseManager
|
from azure_devops_build_manager.release.release_manager import ReleaseManager
|
||||||
from azure_devops_build_manager.pool.pool_manager import PoolManager
|
from azure_devops_build_manager.pool.pool_manager import PoolManager
|
||||||
|
from azure_devops_build_manager.constants import LINUX_CONSUMPTION, LINUX_DEDICATED, WINDOWS
|
||||||
|
from ._config import CREATE_DEVOPS_OBJECTS, ORGANIZATION_NAME, PROJECT_NAME, REPOSITORY_NAME, SERVICE_ENDPOINT_NAME, BUILD_DEFINITION_NAME, RELEASE_DEFINITION_NAME, POOL_NAME, FUNCTIONAPP_NAME, STORAGE_NAME, RESOURCE_GROUP_NAME
|
||||||
|
from ._helpers import get_credentials
|
||||||
|
|
||||||
LINUX_CONSUMPTION = 0
|
|
||||||
LINUX_DEDICATED = 1
|
|
||||||
WINDOWS = 2
|
|
||||||
|
|
||||||
class TestReleaseManager(unittest.TestCase):
|
class TestReleaseManager(unittest.TestCase):
|
||||||
|
|
||||||
def test_release_definition(self):
|
def test_list_release_definitions(self):
|
||||||
cli_ctx = get_default_cli()
|
creds = get_credentials()
|
||||||
profile = Profile(cli_ctx=cli_ctx)
|
release_manager = ReleaseManager(organization_name=ORGANIZATION_NAME, project_name=PROJECT_NAME, creds=creds)
|
||||||
creds, _, _ = profile.get_login_credentials(subscription_id=None)
|
release_manager.list_release_definitions()
|
||||||
organization_name = "function-deployments-releases"
|
|
||||||
project_name = "py-consump"
|
def test_list_releases(self):
|
||||||
release_definition_name = "test-4"
|
creds = get_credentials()
|
||||||
release_manager = ReleaseManager(organization_name=organization_name, project_name=project_name, creds=creds)
|
release_manager = ReleaseManager(organization_name=ORGANIZATION_NAME, project_name=PROJECT_NAME, creds=creds)
|
||||||
release_manager.create_release_definition(project_name, 'drop', "Hosted VS2017", organization_name+project_name, release_definition_name,
|
release_manager.list_releases()
|
||||||
LINUX_CONSUMPTION, 'dolk-python-consumption-2', 'dolkpythonconsuacfd', 'dolk-python-consumption-2')
|
|
||||||
|
@unittest.skipIf(CREATE_DEVOPS_OBJECTS == False,
|
||||||
|
"skipping - set CREATE_DEVOPS_OBJECTS to True if you don't want to skip creates")
|
||||||
|
def test_basic_release(self):
|
||||||
|
creds = get_credentials()
|
||||||
|
release_manager = ReleaseManager(organization_name=ORGANIZATION_NAME, project_name=PROJECT_NAME, creds=creds)
|
||||||
|
release_manager.create_release_definition(PROJECT_NAME, 'drop', "Hosted VS2017", SERVICE_ENDPOINT_NAME, RELEASE_DEFINITION_NAME,
|
||||||
|
LINUX_CONSUMPTION, FUNCTIONAPP_NAME, STORAGE_NAME, RESOURCE_GROUP_NAME)
|
||||||
|
|
||||||
release_manager.create_release(release_definition_name)
|
release_manager.create_release(release_definition_name)
|
||||||
|
|
||||||
|
|
|
@ -1,26 +1,38 @@
|
||||||
|
# --------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
# Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
|
# --------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
import unittest, string, random
|
import unittest, string, random
|
||||||
from azure.cli.core import get_default_cli
|
from azure.cli.core import get_default_cli
|
||||||
from azure.cli.core._profile import Profile
|
from azure.cli.core._profile import Profile
|
||||||
from azure_devops_build_manager.respository.repository_manager import RepositoryManager
|
from azure_devops_build_manager.respository.repository_manager import RepositoryManager
|
||||||
|
from ._config import ORGANIZATION_NAME, PROJECT_NAME, REPOSITORY_NAME
|
||||||
|
from ._helpers import get_credentials
|
||||||
|
|
||||||
class TestRepositoryManager(unittest.TestCase):
|
class TestRepositoryManager(unittest.TestCase):
|
||||||
|
|
||||||
def test_create_repository(self):
|
def test_list_commits(self):
|
||||||
print("unimplemented")
|
creds = get_credentials()
|
||||||
|
repository_manager = RepositoryManager(organization_name=ORGANIZATION_NAME, project_name=PROJECT_NAME, creds=creds)
|
||||||
|
commits = (repository_manager.list_commits(REPOSITORY_NAME))
|
||||||
|
|
||||||
|
def test_list_repositories(self):
|
||||||
|
creds = get_credentials()
|
||||||
|
repository_manager = RepositoryManager(organization_name=ORGANIZATION_NAME, project_name=PROJECT_NAME, creds=creds)
|
||||||
|
repositories = repository_manager.list_repositories()
|
||||||
|
|
||||||
def test_list_repository(self):
|
|
||||||
print("unimplemented")
|
|
||||||
|
|
||||||
def test_get_repository_commits(self):
|
def test_github(self):
|
||||||
cli_ctx = get_default_cli()
|
creds = get_credentials()
|
||||||
profile = Profile(cli_ctx=cli_ctx)
|
repository_manager = RepositoryManager(organization_name=ORGANIZATION_NAME, project_name=PROJECT_NAME, creds=creds)
|
||||||
creds, _, _ = profile.get_login_credentials(subscription_id=None)
|
print(repository_manager._github())
|
||||||
organization_name = "final-tests-az"
|
|
||||||
project_name = "None"
|
def test_get_github(self):
|
||||||
repository_name = "None"
|
creds = get_credentials()
|
||||||
repository_manager = RepositoryManager(organization_name=organization_name, project_name=project_name, creds=creds)
|
repository_manager = RepositoryManager(organization_name=ORGANIZATION_NAME, project_name=PROJECT_NAME, creds=creds)
|
||||||
print(repository_manager.get_repository_commits(repository_name))
|
for repo in (repository_manager._get_github_repsotories().repositories):
|
||||||
|
print(repo)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
|
@ -1,18 +1,32 @@
|
||||||
from __future__ import print_function
|
# --------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
# Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
|
# --------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import unittest, string, random
|
import unittest, string, random
|
||||||
from azure.cli.core import get_default_cli
|
from azure.cli.core import get_default_cli
|
||||||
from azure.cli.core._profile import Profile
|
from azure.cli.core._profile import Profile
|
||||||
from azure_devops_build_manager.yaml.yaml_manager import YamlManager
|
from azure_devops_build_manager.service_endpoint.service_endpoint_manager import ServiceEndpointManager
|
||||||
from azure_devops_build_manager.constants import LINUX_CONSUMPTION, LINUX_DEDICATED, WINDOWS, PYTHON, JAVA, NET, NODE
|
from ._config import ORGANIZATION_NAME, PROJECT_NAME, SERVICE_ENDPOINT_NAME, CREATE_DEVOPS_OBJECTS
|
||||||
|
from ._helpers import get_credentials
|
||||||
|
|
||||||
class TestYamlManager(unittest.TestCase):
|
|
||||||
|
|
||||||
def test_create_yaml(self):
|
class TestServiceEndpointManager(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_list_service_endpoint(self):
|
||||||
|
creds = get_credentials()
|
||||||
|
service_endpoint_manager = ServiceEndpointManager(organization_name=ORGANIZATION_NAME, project_name=PROJECT_NAME, creds=creds)
|
||||||
|
endpoints = service_endpoint_manager.list_service_endpoints()
|
||||||
|
found_endpoint = next((endpoint for endpoint in endpoints if endpoint.name == SERVICE_ENDPOINT_NAME), None)
|
||||||
|
self.assertTrue(found_endpoint != None)
|
||||||
|
|
||||||
yaml_manager = YamlManager(JAVA, WINDOWS)
|
@unittest.skipIf(CREATE_DEVOPS_OBJECTS == False,
|
||||||
|
"skipping - set CREATE_DEVOPS_OBJECTS to True if you don't want to skip creates")
|
||||||
print(yaml_manager.create_yaml("{functionapp_name}", "{subscription_name}", "{storage_name}", True))
|
def test_create_service_endpoint(self):
|
||||||
|
creds = get_credentials()
|
||||||
|
service_endpoint_manager = ServiceEndpointManager(organization_name=ORGANIZATION_NAME, project_name=PROJECT_NAME, creds=creds)
|
||||||
|
endpoint = service_endpoint_manager.create_service_endpoint(SERVICE_ENDPOINT_NAME)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -1,19 +1,22 @@
|
||||||
from __future__ import print_function
|
# --------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
# Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
|
# --------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import unittest, string, random
|
import unittest, string, random
|
||||||
from azure.cli.core import get_default_cli
|
from azure.cli.core import get_default_cli
|
||||||
from azure.cli.core._profile import Profile
|
from azure.cli.core._profile import Profile
|
||||||
from azure_devops_build_manager.yaml.yaml_manager import YamlManager
|
from azure_devops_build_manager.yaml.yaml_manager import YamlManager
|
||||||
from azure_devops_build_manager.constants import LINUX_CONSUMPTION, LINUX_DEDICATED, WINDOWS, PYTHON, JAVA, NET, NODE
|
from azure_devops_build_manager.constants import LINUX_CONSUMPTION, LINUX_DEDICATED, WINDOWS, PYTHON, JAVA, NET, NODE
|
||||||
|
from ._config import FUNCTIONAPP_NAME, SUBSCRIPTION_NAME, STORAGE_NAME
|
||||||
|
|
||||||
class TestYamlManager(unittest.TestCase):
|
class TestYamlManager(unittest.TestCase):
|
||||||
|
|
||||||
def test_create_yaml(self):
|
def test_create_yaml(self):
|
||||||
|
yaml_manager = YamlManager(PYTHON, LINUX_DEDICATED)
|
||||||
yaml_manager = YamlManager(JAVA, WINDOWS)
|
# We don't usually use the file path but for testing we need to make sure we create the azure pipelines file in the right file
|
||||||
|
yaml_manager.create_yaml(file_path="python_test_application/azure-pipelines.yml")
|
||||||
print(yaml_manager.create_yaml("{functionapp_name}", "{subscription_name}", "{storage_name}", True))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
Загрузка…
Ссылка в новой задаче