Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down