class TestCommand(unittest.TestCase):

    def setUp(self):
        self.alarm_update = AlarmUpdate()
        pass

    def test_cli_description(self):
        self.assertEqual('Updates a alarm definition in an Boundary account',
                         self.alarm_update.getDescription(), 'Check AlarmCreate description')
Beispiel #2
0
    def test_update_alarm(self):
        alarm_name = 'my-alarm-' + CLITest.random_string(6)
        metric_name = 'CPU'
        note = CLITest.random_string(50)
        aggregate = 'max'
        op = 'gt'
        value = 0.75
        trigger_interval = 900000
        is_disabled = True
        runner_create = CLIRunner(AlarmCreate())
        create = runner_create.get_output([
            '-n', alarm_name, '-m', metric_name, '-d', note, '-g', aggregate,
            '-o', op, '-v',
            str(value), '-r',
            str(trigger_interval), '-x',
            str(is_disabled).lower()
        ])
        alarm_create = json.loads(create)

        note = CLITest.random_string(50)
        aggregate = 'max'
        op = 'gt'
        value = 0.75
        trigger_interval = 300000
        is_disabled = False

        runner_update = CLIRunner(AlarmUpdate())
        update = runner_update.get_output([
            '-i',
            str(int(alarm_create['id'])), '-n', alarm_name, '-m', metric_name,
            '-d', note, '-g', aggregate, '-o', op, '-v',
            str(value), '-r',
            str(trigger_interval), '-x',
            str(is_disabled).lower()
        ])
        alarm = json.loads(update)

        self.assertEqual(trigger_interval, alarm['triggerInterval'])
        self.assertEqual(1, alarm['familyId'])
        self.assertFalse(is_disabled, alarm['isDisabled'])
        self.assertEqual(metric_name, alarm['metric'])
        self.assertEqual(alarm_name, alarm['name'])
        self.assertEqual(aggregate, alarm['triggerPredicate']['agg'])
        self.assertEqual(op, alarm['triggerPredicate']['op'])
        self.assertEqual(value, alarm['triggerPredicate']['val'])
        self.assertEqual(3, int(alarm['typeId']))
        self.assertEqual(note, alarm['note'])

        runner_delete = CLIRunner(AlarmDelete())
        delete = runner_delete.get_output(['-i', str(alarm['id'])])
 def setUp(self):
     self.alarm_update = AlarmUpdate()
     pass
Beispiel #4
0
 def alarm_update(self, **kwargs):
     api = AlarmUpdate()
     api._kwargs = kwargs
     return api.api_call()
Beispiel #5
0
 def alarm_update(self, **kwargs):
     api = AlarmUpdate()
     api._kwargs = kwargs
     return api.api_call()
Beispiel #6
0
 def setUp(self):
     self.cli = AlarmUpdate()
     self.api = API()