def test_config_source_control_vsts(self, profile_mock, cd_manager_mock, client_factory_mock): # Mock the result of get auth token (avoiding REST call) profile = mock.Mock() profile.get_subscription.return_value = {'id': 'id1', 'name': 'sub1', 'tenantId': 'tenant1'} profile.get_current_account_user.return_value = None profile.get_login_credentials.return_value = None, None, None profile.get_access_token_for_resource.return_value = None profile_mock.return_value = profile # Mock the cd manager class so no REST calls are made cd_manager = mock.Mock() status = ContinuousDeliveryResult(None, None, None, None, None, None, "message1", None, None, None) cd_manager.setup_continuous_delivery.return_value = status cd_manager_mock.return_value = cd_manager # Mock the client and set the location client = mock.Mock() client_factory_mock.return_value = client site = Site('antarctica') site.default_host_name = 'myweb.com' client.web_apps.get.return_value = site config_source_control('group1', 'myweb', 'http://github.com/repo1', None, None, None, None, "slot1", 'vsts', 'ASPNetWap', 'account1', False) cd_manager.setup_continuous_delivery.assert_called_with('slot1', 'ASPNetWap', 'account1', True, None)
def publish_app(cmd, resource_group_name, resource_name, git_url=None, git_token=None, git_branch='master', # pylint: disable=inconsistent-return-statements code_dir=None): # if given msbot json, use that to update environment settings like luis settings if git_url: return config_source_control( cmd=cmd, name=resource_name, resource_group_name=resource_group_name, repo_url=git_url, branch=git_branch, git_token=git_token ) # since there is no git url it's definitely publish from local if not code_dir: code_dir = os.getcwd() if code_dir: if not os.path.isdir(code_dir): raise CLIError('Please supply a valid directory path containing your source code') # ensure that the directory contains appropriate post deploy scripts folder if 'PostDeployScripts' not in os.listdir(code_dir): raise CLIError('Not a valid azure publish directory. missing post deploy scripts') shutil.make_archive('upload', 'zip', code_dir) output = enable_zip_deploy(cmd, resource_group_name, resource_name, 'upload.zip') os.remove('upload.zip') return output
def test_config_source_control_vsts(self, profile_mock, cd_manager_mock, client_factory_mock): # Mock the result of get auth token (avoiding REST call) profile = mock.Mock() profile.get_subscription.return_value = { 'id': 'id1', 'name': 'sub1', 'tenantId': 'tenant1' } profile.get_current_account_user.return_value = None profile.get_login_credentials.return_value = None, None, None profile.get_access_token_for_resource.return_value = None profile_mock.return_value = profile # Mock the cd manager class so no REST calls are made cd_manager = mock.Mock() status = ContinuousDeliveryResult(None, None, None, None, None, None, "message1", None, None, None) cd_manager.setup_continuous_delivery.return_value = status cd_manager_mock.return_value = cd_manager # Mock the client and set the location client = mock.Mock() client_factory_mock.return_value = client cmd_mock = _get_test_cmd() Site = cmd_mock.get_models('Site') site = Site(name='antarctica', location='westus') site.default_host_name = 'myweb.com' client.web_apps.get.return_value = site config_source_control(mock.MagicMock(), 'group1', 'myweb', 'http://github.com/repo1', None, None, None, None, None, 'ASPNet', 'working_directory', 'Gulp', 'Django', 'Python 2.7.12 x64', True, 'https://account1.visualstudio.com', None, 'slot1', None, None) cd_app_type_details = { 'cd_app_type': 'ASPNet', 'app_working_dir': 'working_directory', 'nodejs_task_runner': 'Gulp', 'python_framework': 'Django', 'python_version': 'Python 2.7.12 x64' } cd_manager.setup_continuous_delivery.assert_called_with( 'slot1', cd_app_type_details, 'https://account1.visualstudio.com', True, None, None, None)
def test_config_source_control_vsts(self, profile_mock, cd_manager_mock, client_factory_mock): # Mock the result of get auth token (avoiding REST call) profile = mock.Mock() profile.get_subscription.return_value = {'id': 'id1', 'name': 'sub1', 'tenantId': 'tenant1'} profile.get_current_account_user.return_value = None profile.get_login_credentials.return_value = None, None, None profile.get_access_token_for_resource.return_value = None profile_mock.return_value = profile # Mock the cd manager class so no REST calls are made cd_manager = mock.Mock() status = ContinuousDeliveryResult(None, None, None, None, None, None, "message1", None, None, None) cd_manager.setup_continuous_delivery.return_value = status cd_manager_mock.return_value = cd_manager # Mock the client and set the location client = mock.Mock() client_factory_mock.return_value = client site = Site('antarctica') site.default_host_name = 'myweb.com' client.web_apps.get.return_value = site config_source_control(mock.MagicMock(), 'group1', 'myweb', 'http://github.com/repo1', None, None, None, None, None, 'ASPNet', 'working_directory', 'Gulp', 'Django', 'Python 2.7.12 x64', True, 'https://account1.visualstudio.com', None, 'slot1', None, None) cd_app_type_details = { 'cd_app_type': 'ASPNet', 'app_working_dir': 'working_directory', 'nodejs_task_runner': 'Gulp', 'python_framework': 'Django', 'python_version': 'Python 2.7.12 x64' } cd_manager.setup_continuous_delivery.assert_called_with('slot1', cd_app_type_details, 'https://account1.visualstudio.com', True, None, None, None)