~ubuntu-branches/ubuntu/vivid/ceilometer/vivid-proposed

« back to all changes in this revision

Viewing changes to ceilometer/tests/alarm/evaluator/test_combination.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2014-06-13 13:20:35 UTC
  • mfrom: (1.1.17)
  • Revision ID: package-import@ubuntu.com-20140613132035-42ibzh8j7ww2q31i
Tags: 2014.2~b1-0ubuntu1
* New upstream release.
* debian/control: Open up juno release
* debian/patches/fix-requirements.patch: Refreshed.
* debian/rules: Patch the ceilometer.conf.sample directly since
  the configuration files are generated by a tool.
* debian/ceilometer-common.install: Drop sources.json.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- encoding: utf-8 -*-
2
1
#
3
 
# Copyright © 2013 eNovance <licensing@enovance.com>
 
2
# Copyright 2013 eNovance <licensing@enovance.com>
4
3
#
5
4
# Authors: Mehdi Abaakouk <mehdi.abaakouk@enovance.com>
6
5
#
310
309
 
311
310
            self.assertEqual(expected, self.notifier.notify.call_args_list)
312
311
 
313
 
    def test_state_change_inside_time_constraint(self):
 
312
    @mock.patch.object(timeutils, 'utcnow')
 
313
    def test_state_change_inside_time_constraint(self, mock_utcnow):
314
314
        self._set_all_alarms('insufficient data')
315
315
        self.alarms[0].time_constraints = [
316
316
            {'name': 'test',
322
322
        self.alarms[1].time_constraints = self.alarms[0].time_constraints
323
323
        dt = datetime.datetime(2014, 1, 1, 12, 0, 0,
324
324
                               tzinfo=pytz.timezone('Europe/Ljubljana'))
 
325
        mock_utcnow.return_value = dt.astimezone(pytz.UTC)
325
326
        with mock.patch('ceilometerclient.client.get_client',
326
327
                        return_value=self.api_client):
327
 
            timeutils.set_time_override(dt.astimezone(pytz.UTC))
328
328
            self.api_client.alarms.get.side_effect = [
329
329
                self._get_alarm('ok'),
330
330
                self._get_alarm('ok'),
348
348
                        in zip(self.alarms, reasons, reason_datas)]
349
349
            self.assertEqual(expected, self.notifier.notify.call_args_list)
350
350
 
351
 
    def test_no_state_change_outside_time_constraint(self):
 
351
    @mock.patch.object(timeutils, 'utcnow')
 
352
    def test_no_state_change_outside_time_constraint(self, mock_utcnow):
352
353
        self._set_all_alarms('insufficient data')
353
354
        self.alarms[0].time_constraints = [
354
355
            {'name': 'test',
360
361
        self.alarms[1].time_constraints = self.alarms[0].time_constraints
361
362
        dt = datetime.datetime(2014, 1, 1, 15, 0, 0,
362
363
                               tzinfo=pytz.timezone('Europe/Ljubljana'))
 
364
        mock_utcnow.return_value = dt.astimezone(pytz.UTC)
363
365
        with mock.patch('ceilometerclient.client.get_client',
364
366
                        return_value=self.api_client):
365
 
            timeutils.set_time_override(dt.astimezone(pytz.UTC))
366
367
            self.api_client.alarms.get.side_effect = [
367
368
                self._get_alarm('ok'),
368
369
                self._get_alarm('ok'),