diff --git a/src/azure-cli/azure/cli/command_modules/appservice/custom.py b/src/azure-cli/azure/cli/command_modules/appservice/custom.py index f1da24aa73a..727c8ac2423 100644 --- a/src/azure-cli/azure/cli/command_modules/appservice/custom.py +++ b/src/azure-cli/azure/cli/command_modules/appservice/custom.py @@ -4964,6 +4964,7 @@ def delete_function_key(cmd, resource_group_name, name, key_name, function_name= def add_github_actions(cmd, resource_group, name, repo, runtime=None, token=None, slot=None, # pylint: disable=too-many-statements,too-many-branches branch='master', login_with_github=False, force=False): + runtime = _StackRuntimeHelper(cmd).remove_delimiters(runtime) # normalize "runtime:version" if not token and not login_with_github: raise_missing_token_suggestion() elif not token: diff --git a/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_webapp_commands_thru_mock.py b/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_webapp_commands_thru_mock.py index cbaa0c43117..0d9db512444 100644 --- a/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_webapp_commands_thru_mock.py +++ b/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_webapp_commands_thru_mock.py @@ -25,7 +25,8 @@ restore_deleted_webapp, list_snapshots, restore_snapshot, - create_managed_ssl_cert) + create_managed_ssl_cert, + add_github_actions) # pylint: disable=line-too-long from azure.cli.core.profiles import ResourceType @@ -47,6 +48,30 @@ class TestWebappMocked(unittest.TestCase): def setUp(self): self.client = WebSiteManagementClient(mock.MagicMock(), '123455678') + @mock.patch('azure.cli.command_modules.appservice.custom._update_site_source_control_properties_for_gh_action') + @mock.patch('azure.cli.command_modules.appservice.custom._add_publish_profile_to_github') + @mock.patch('azure.cli.command_modules.appservice.custom.prompt_y_n') + @mock.patch('azure.cli.command_modules.appservice.custom._get_app_runtime_info') + @mock.patch('github.Github') + @mock.patch('azure.cli.command_modules.appservice.custom.parse_resource_id') + @mock.patch('azure.cli.command_modules.appservice.custom.get_site_availability') + @mock.patch('azure.cli.command_modules.appservice.custom.web_client_factory') + @mock.patch('azure.cli.command_modules.appservice.custom.get_app_details') + def test_webapp_github_actions_add(self, get_app_details_mock, web_client_factory_mock, site_availability_mock, *args): + runtime = "python:3.9" + rg = "group" + is_linux = True + cmd = _get_test_cmd() + get_app_details_mock.return_value = mock.Mock() + get_app_details_mock.return_value.resource_group = rg + web_client_factory_mock.return_value.app_service_plans.get.return_value.reserved = is_linux + site_availability_mock.return_value.name_available = False + + with mock.patch('azure.cli.command_modules.appservice.custom._runtime_supports_github_actions', autospec=True) as m: + add_github_actions(cmd, rg, "name", "repo", runtime, "token") + m.assert_called_with(cmd, runtime.replace(":", "|"), is_linux) + + @mock.patch('azure.cli.command_modules.appservice.custom.web_client_factory', autospec=True) def test_set_deployment_user_creds(self, client_factory_mock): class MockClient: