Skip to content
Open
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
4 changes: 3 additions & 1 deletion src/azure-cli/azure/cli/command_modules/mysql/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ def flexible_server_advanced_threat_protection_update(cmd, client, resource_grou
Updates an advanced threat protection setting. Custom update function to apply parameters to instance.
'''
parameters = {
'state': state
'properties': {
'state': state
}
}
return client.begin_update(resource_group_name, server_name, models.AdvancedThreatProtectionName.DEFAULT.value, parameters)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,28 @@ def test_firewall_rule_create_uses_properties_payload(self):
}, client.parameters.as_dict())


class MysqlFlexibleServerAdvancedThreatProtectionCustomTest(unittest.TestCase):

def test_update_uses_properties_payload(self):
client = _FakeAdvancedThreatProtectionClient()

custom.flexible_server_advanced_threat_protection_update(
cmd=None,
client=client,
resource_group_name='rg',
server_name='server',
state='Enabled')

self.assertEqual('rg', client.resource_group_name)
self.assertEqual('server', client.server_name)
self.assertEqual('Default', client.advanced_threat_protection_name)
self.assertEqual({
'properties': {
'state': 'Enabled'
}
}, client.parameters)


class _FakeFirewallRulesClient:

def begin_create_or_update(self, resource_group_name, server_name, firewall_rule_name, parameters):
Expand All @@ -44,5 +66,15 @@ def begin_create_or_update(self, resource_group_name, server_name, firewall_rule
return parameters


class _FakeAdvancedThreatProtectionClient:

def begin_update(self, resource_group_name, server_name, advanced_threat_protection_name, parameters):
self.resource_group_name = resource_group_name
self.server_name = server_name
self.advanced_threat_protection_name = advanced_threat_protection_name
self.parameters = parameters
return parameters


if __name__ == '__main__':
unittest.main()
Loading