This file is indexed.

/usr/lib/python2.7/dist-packages/aodhclient/tests/unit/test_alarm_manager.py is in python-aodhclient 0.3.0-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#
#    Copyright IBM 2016. All rights reserved
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

import mock
import testtools

from aodhclient.v2 import alarm


class AlarmManagerTest(testtools.TestCase):

    def setUp(self):
        super(AlarmManagerTest, self).setUp()
        self.client = mock.Mock()
        self.alarms = {
            'event_alarm': {
                'gnocchi_aggregation_by_metrics_threshold_rule': {},
                'gnocchi_resources_threshold_rule': {},
                'name': 'event_alarm',
                'threshold_rule': {},
                'gnocchi_aggregation_by_resources_threshold_rule': {},
                'event_rule': {},
                'type': 'event'}
        }
        self.results = {
            "result1": {
                "event_rule": {}
            },
        }

    @mock.patch.object(alarm.AlarmManager, '_get')
    def test_list(self, mock_am):
        am = alarm.AlarmManager(self.client)
        am.list('event')
        mock_am.assert_called_with(
            'v2/alarms?q.field=type&q.op=eq&q.value=event')

    @mock.patch.object(alarm.AlarmManager, '_get')
    def test_get(self, mock_am):
        am = alarm.AlarmManager(self.client)
        am.get('01919bbd-8b0e-451c-be28-abe250ae9b1b')
        mock_am.assert_called_with(
            'v2/alarms/01919bbd-8b0e-451c-be28-abe250ae9b1b')

    @mock.patch.object(alarm.AlarmManager, '_delete')
    def test_delete(self, mock_am):
        am = alarm.AlarmManager(self.client)
        am.delete('01919bbd-8b0e-451c-be28-abe250ae9b1b')
        mock_am.assert_called_with(
            'v2/alarms/01919bbd-8b0e-451c-be28-abe250ae9b1b')

    def test_clean_rules_event_alarm(self):
        am = alarm.AlarmManager(self.client)
        alarm_value = self.alarms.get('event_alarm')
        am._clean_rules('event', alarm_value)
        alarm_value.pop('type')
        alarm_value.pop('name')
        result = self.results.get("result1")
        self.assertEqual(alarm_value, result)

    @mock.patch.object(alarm.AlarmManager, '_post')
    def test_search(self, mock_am):
        am = alarm.AlarmManager(self.client)
        query = '{"=": {"type": "event"}}'
        am.search(query)
        url = 'v2/query/alarms'
        expected_value = ('{"filter": "{\\"=\\": {\\"type\\":'
                          ' \\"event\\"}}"}')
        headers_value = {'Content-Type': "application/json"}
        mock_am.assert_called_with(
            url,
            data=expected_value,
            headers=headers_value)