Merge "Use assert_called_once_with() in test_alarm_cli.py"

This commit is contained in:
Jenkins 2016-03-08 09:25:44 +00:00 committed by Gerrit Code Review
commit 19e44f5a78

View File

@ -38,16 +38,16 @@ class CliAlarmCreateTest(testtools.TestCase):
test_parsed_args = parser.parse_args([ test_parsed_args = parser.parse_args([
'--name', 'gnocchi_resources_threshold_test', '--name', 'gnocchi_resources_threshold_test',
'--type', 'gnocchi_resources_threshold', '--type', 'gnocchi_resources_threshold',
'--metric', 'cpu' '--metric', 'cpu',
'--aggregation_method', 'last', '--aggregation-method', 'last',
'--resource-type', 'generic', '--resource-type', 'generic',
'--threshold', '80' '--threshold', '80'
]) ])
self.cli_alarm_create._validate_args(test_parsed_args) self.cli_alarm_create._validate_args(test_parsed_args)
mock_arg.assert_called_with( mock_arg.assert_called_once_with(
'gnocchi_resources_threshold requires --metric' 'gnocchi_resources_threshold requires --metric, '
', --threshold, --resource-id, --resource-type ' '--threshold, --resource-id, --resource-type and '
'and --aggregation-method') '--aggregation-method')
@mock.patch.object(argparse.ArgumentParser, 'error') @mock.patch.object(argparse.ArgumentParser, 'error')
def test_validate_args_threshold(self, mock_arg): def test_validate_args_threshold(self, mock_arg):
@ -60,7 +60,7 @@ class CliAlarmCreateTest(testtools.TestCase):
'--threshold', '80' '--threshold', '80'
]) ])
self.cli_alarm_create._validate_args(test_parsed_args) self.cli_alarm_create._validate_args(test_parsed_args)
mock_arg.assert_called_with( mock_arg.assert_called_once_with(
'threshold alarm requires -m/--meter-name and ' 'threshold alarm requires -m/--meter-name and '
'--threshold parameters') '--threshold parameters')
@ -73,15 +73,14 @@ class CliAlarmCreateTest(testtools.TestCase):
'--name', 'gnocchi_aggregation_by_resources_threshold_test', '--name', 'gnocchi_aggregation_by_resources_threshold_test',
'--type', 'gnocchi_aggregation_by_resources_threshold', '--type', 'gnocchi_aggregation_by_resources_threshold',
'--metric', 'cpu', '--metric', 'cpu',
'--aggregation_method', 'last', '--aggregation-method', 'last',
'--resource-type', 'generic', '--resource-type', 'generic',
'--threshold', '80' '--threshold', '80'
]) ])
self.cli_alarm_create._validate_args(test_parsed_args) self.cli_alarm_create._validate_args(test_parsed_args)
mock_arg.assert_called_with( mock_arg.assert_called_once_with(
'gnocchi_aggregation_by_resources_threshold ' 'gnocchi_aggregation_by_resources_threshold requires '
'requires --metric, --threshold, ' '--metric, --threshold, --aggregation-method, --query and '
'--aggregation-method, --query and '
'--resource-type') '--resource-type')
@mock.patch.object(argparse.ArgumentParser, 'error') @mock.patch.object(argparse.ArgumentParser, 'error')
@ -96,10 +95,9 @@ class CliAlarmCreateTest(testtools.TestCase):
'--threshold', '80' '--threshold', '80'
]) ])
self.cli_alarm_create._validate_args(test_parsed_args) self.cli_alarm_create._validate_args(test_parsed_args)
mock_arg.assert_called_with( mock_arg.assert_called_once_with(
'gnocchi_aggregation_by_metrics_threshold' 'gnocchi_aggregation_by_metrics_threshold requires '
' requires --metrics, --threshold and ' '--metrics, --threshold and --aggregation-method')
'--aggregation-method')
def test_alarm_from_args(self): def test_alarm_from_args(self):
# The test case to cover the method _alarm_from_args # The test case to cover the method _alarm_from_args