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

« back to all changes in this revision

Viewing changes to ceilometer/tests/alarm/test_alarm_svc.py

  • Committer: Package Import Robot
  • Author(s): James Page, Corey Bryant, James Page
  • Date: 2015-02-19 14:59:07 UTC
  • mfrom: (1.2.3)
  • Revision ID: package-import@ubuntu.com-20150219145907-9jojybdsl64zcn14
Tags: 2015.1~b2-0ubuntu1
[ Corey Bryant ]
* New upstream release.
  - d/control: Align requirements with upstream.
  - d/p/skip-test.patch: Rebased.

[ James Page ]
* d/rules,d/p/skip-gabbi.patch: Skip tests that rely on python-gabbi until
  packaging and MIR is complete.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#
2
2
# Copyright 2013 Red Hat, Inc
3
3
#
4
 
# Author: Eoghan Glynn <eglynn@redhat.com>
5
 
#
6
4
# Licensed under the Apache License, Version 2.0 (the "License"); you may
7
5
# not use this file except in compliance with the License. You may obtain
8
6
# a copy of the License at
17
15
"""Tests for ceilometer.alarm.service.SingletonAlarmService.
18
16
"""
19
17
import mock
20
 
from oslo.config import fixture as fixture_config
 
18
from oslo_config import fixture as fixture_config
21
19
from stevedore import extension
22
20
 
23
21
from ceilometer.alarm import service
107
105
                self.svc.PARTITIONING_GROUP_NAME, [alarm])
108
106
            self.threshold_eval.evaluate.assert_called_once_with(alarm)
109
107
 
 
108
    def test_evaluation_cycle_with_bad_alarm(self):
 
109
        alarms = [
 
110
            mock.Mock(type='threshold', name='bad'),
 
111
            mock.Mock(type='threshold', name='good'),
 
112
        ]
 
113
        self.api_client.alarms.list.return_value = alarms
 
114
        self.threshold_eval.evaluate.side_effect = [Exception('Boom!'), None]
 
115
        with mock.patch('ceilometerclient.client.get_client',
 
116
                        return_value=self.api_client):
 
117
            p_coord_mock = self.svc.partition_coordinator
 
118
            p_coord_mock.extract_my_subset.return_value = alarms
 
119
 
 
120
            self.svc._evaluate_assigned_alarms()
 
121
            self.assertEqual([mock.call(alarms[0]), mock.call(alarms[1])],
 
122
                             self.threshold_eval.evaluate.call_args_list)
 
123
 
110
124
    def test_unknown_extension_skipped(self):
111
125
        alarms = [
112
126
            mock.Mock(type='not_existing_type'),