Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Modified the update method for managementgroups and re-ran tests in l…
…ive mode
  • Loading branch information
git-thomasdolan committed Jan 12, 2022
commit f6bcc41549853415f65f282f5e2f66d0b9667041
19 changes: 10 additions & 9 deletions src/azure-cli/azure/cli/command_modules/resource/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,15 +459,16 @@ def load_command_table(self, _):
g.custom_show_command('show', 'cli_managementgroups_group_show')
g.custom_command('create', 'cli_managementgroups_group_create')
g.custom_command('delete', 'cli_managementgroups_group_delete')
g.generic_update_command(
'update',
getter_name='cli_managementgroups_group_update_get',
getter_type=resource_managementgroups_update_type,
setter_name='cli_managementgroups_group_update_set',
setter_type=resource_managementgroups_update_type,
custom_func_name='cli_managementgroups_group_update_custom_func',
custom_func_type=resource_managementgroups_update_type,
exception_handler=managementgroups_exception_handler)
g.custom_command('update', 'cli_managementgroups_group_create')
#g.generic_update_command(
#'update',
#getter_name='cli_managementgroups_group_update_get',
#getter_type=resource_managementgroups_update_type,
#setter_name='cli_managementgroups_group_update_set',
#setter_type=resource_managementgroups_update_type,
#custom_func_name='cli_managementgroups_group_update_custom_func',
#custom_func_type=resource_managementgroups_update_type,
#exception_handler=managementgroups_exception_handler)

with self.command_group('account management-group subscription', resource_managementgroups_subscriptions_sdk, client_factory=cf_management_group_subscriptions) as g:
g.custom_command('add', 'cli_managementgroups_subscription_add')
Expand Down
6 changes: 3 additions & 3 deletions src/azure-cli/azure/cli/command_modules/resource/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2888,15 +2888,15 @@ def cli_managementgroups_group_update_custom_func(
instance,
display_name=None,
parent_id=None):
parent_id = _get_parent_id_from_parent(parent_id)
parent_group_id = _get_parent_id_from_parent(parent_id)
instance.display_name = display_name
instance.parent_id = parent_id
instance.parent_group_id = parent_group_id
return instance


def cli_managementgroups_group_update_get():
from azure.mgmt.managementgroups.models import PatchManagementGroupRequest
update_parameters = PatchManagementGroupRequest(display_name=None, parent_id=None)
update_parameters = PatchManagementGroupRequest(display_name=None, parent_group_id=None)
return update_parameters


Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ def test_show_managementgroup_with_expand(self):
self.assertIsNotNone(managementgroup_get["tenantId"])
self.assertEqual(
managementgroup_get["type"],
"/providers/Microsoft.Management/managementGroups")
"Microsoft.Management/managementGroups")
self.assertEqual(
managementgroup_get["children"][0]["id"],
"/providers/Microsoft.Management/managementGroups/testcligetgroup3")
self.assertEqual(
managementgroup_get["children"][0]["type"],
"/providers/Microsoft.Management/managementGroups")
"Microsoft.Management/managementGroups")
self.assertEqual(
managementgroup_get["children"][0]["displayName"],
"testcligetgroup3")
Expand Down Expand Up @@ -133,13 +133,13 @@ def test_show_managementgroup_with_expand_and_recurse(self):
self.assertIsNotNone(managementgroup_get["tenantId"])
self.assertEqual(
managementgroup_get["type"],
"/providers/Microsoft.Management/managementGroups")
"Microsoft.Management/managementGroups")
self.assertEqual(
managementgroup_get["children"][0]["id"],
"/providers/Microsoft.Management/managementGroups/testcligetgroup3")
self.assertEqual(
managementgroup_get["children"][0]["type"],
"/providers/Microsoft.Management/managementGroups")
"Microsoft.Management/managementGroups")
self.assertEqual(
managementgroup_get["children"][0]["displayName"],
"testcligetgroup3")
Expand All @@ -151,7 +151,7 @@ def test_show_managementgroup_with_expand_and_recurse(self):
"/providers/Microsoft.Management/managementGroups/testcligetgroup4")
self.assertEqual(
managementgroup_get["children"][0]["children"][0]["type"],
"/providers/Microsoft.Management/managementGroups")
"Microsoft.Management/managementGroups")
self.assertEqual(
managementgroup_get["children"][0]["children"][0]["displayName"],
"testcligetgroup4")
Expand Down Expand Up @@ -240,27 +240,27 @@ def test_create_managementgroup_with_parentid(self):
self.cmd('account management-group delete --name ' + parentName)

self.assertIsNotNone(managementgroup_create)
self.assertIsNotNone(managementgroup_create["properties"]["details"])
self.assertIsNotNone(managementgroup_create["details"])
self.assertEqual(
managementgroup_create["id"],
"/providers/Microsoft.Management/managementGroups/" + name)
self.assertEqual(managementgroup_create["name"], name)
self.assertEqual(
managementgroup_create["properties"]["displayName"],
managementgroup_create["displayName"],
displayName)
self.assertEqual(
managementgroup_create["properties"]["details"]["parent"]["displayName"],
managementgroup_create["details"]["parent"]["displayName"],
parentName)
self.assertEqual(
managementgroup_create["properties"]["details"]["parent"]["id"],
managementgroup_create["details"]["parent"]["id"],
parentId)
self.assertEqual(
managementgroup_create["properties"]["details"]["parent"]["name"],
managementgroup_create["details"]["parent"]["name"],
parentName)
self.assertIsNotNone(managementgroup_create["properties"]["tenantId"])
self.assertIsNotNone(managementgroup_create["tenantId"])
self.assertEqual(
managementgroup_create["type"],
"/providers/Microsoft.Management/managementGroups")
"Microsoft.Management/managementGroups")

def test_create_managementgroup_with_displayname_and_parentid(self):
name = "testcligroupchild"
Expand Down Expand Up @@ -321,7 +321,7 @@ def test_update_managementgroup_with_displayname(self):
self.assertEqual(managementgroup_update["displayName"], displayName)
self.assertEqual(
managementgroup_update["details"]["parent"]["displayName"],
"Tenant Root Group")
"Root Management Group")
self.assertEqual(
managementgroup_update["details"]["parent"]["id"],
"/providers/Microsoft.Management/managementGroups/" +
Expand All @@ -332,7 +332,7 @@ def test_update_managementgroup_with_displayname(self):
self.assertIsNotNone(managementgroup_update["tenantId"])
self.assertEqual(
managementgroup_update["type"],
"/providers/Microsoft.Management/managementGroups")
"Microsoft.Management/managementGroups")

def test_update_managementgroup_with_parentid(self):
name = "testcligroupchild"
Expand Down Expand Up @@ -369,7 +369,7 @@ def test_update_managementgroup_with_parentid(self):
self.assertIsNotNone(managementgroup_update["tenantId"])
self.assertEqual(
managementgroup_update["type"],
"/providers/Microsoft.Management/managementGroups")
"Microsoft.Management/managementGroups")

def test_update_managementgroup_with_displayname_and_parentid(self):
name = "testcligroupchild"
Expand Down Expand Up @@ -407,7 +407,7 @@ def test_update_managementgroup_with_displayname_and_parentid(self):
self.assertIsNotNone(managementgroup_update["tenantId"])
self.assertEqual(
managementgroup_update["type"],
"/providers/Microsoft.Management/managementGroups")
"Microsoft.Management/managementGroups")

def test_create_delete_group_managementgroup(self):
self.cmd('account management-group create --name testcligroup')
Expand Down