This file is indexed.

/usr/lib/python2.7/dist-packages/heatclient/tests/unit/test_actions.py is in python-heatclient 1.1.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
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
# 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.

from heatclient.tests.unit import fakes
from heatclient.v1 import actions

import testtools


class ActionManagerTest(testtools.TestCase):

    def setUp(self):
        super(ActionManagerTest, self).setUp()

    def _base_test(self, expect_args, expect_kwargs):

        class FakeAPI(object):
            """Fake API and ensure request url is correct."""

            def json_request(self, *args, **kwargs):
                assert expect_args == args
                assert expect_kwargs['data'] == kwargs['data']
                return fakes.FakeHTTPResponse(
                    '200',
                    '',
                    {'content-type': 'application/json'},
                    {}), {}

            def raw_request(self, *args, **kwargs):
                assert expect_args == args
                return fakes.FakeHTTPResponse(
                    '200',
                    '',
                    {},
                    {})

            def head(self, url, **kwargs):
                resp, body = self.json_request("HEAD", url, **kwargs)
                return resp

            def get(self, url, **kwargs):
                resp, body = self.json_request("GET", url, **kwargs)
                return resp

            def post(self, url, **kwargs):
                resp, body = self.json_request("POST", url, **kwargs)
                return resp

            def put(self, url, **kwargs):
                resp, body = self.json_request("PUT", url, **kwargs)
                return resp

            def delete(self, url, **kwargs):
                resp, body = self.raw_request("DELETE", url, **kwargs)
                return resp

            def patch(self, url, **kwargs):
                resp, body = self.json_request("PATCH", url, **kwargs)
                return resp

        manager = actions.ActionManager(FakeAPI())
        return manager

    def test_suspend(self):
        fields = {'stack_id': 'teststack%2Fabcd1234'}
        expect_args = ('POST',
                       '/stacks/teststack%2Fabcd1234/actions')
        expect_kwargs = {'data': {'suspend': None}}

        manager = self._base_test(expect_args, expect_kwargs)
        manager.suspend(**fields)

    def test_resume(self):
        fields = {'stack_id': 'teststack%2Fabcd1234'}
        expect_args = ('POST',
                       '/stacks/teststack%2Fabcd1234/actions')
        expect_kwargs = {'data': {'resume': None}}

        manager = self._base_test(expect_args, expect_kwargs)
        manager.resume(**fields)

    def test_cancel_update(self):
        fields = {'stack_id': 'teststack%2Fabcd1234'}
        expect_args = ('POST',
                       '/stacks/teststack%2Fabcd1234/actions')
        expect_kwargs = {'data': {'cancel_update': None}}

        manager = self._base_test(expect_args, expect_kwargs)
        manager.cancel_update(**fields)

    def test_check(self):
        fields = {'stack_id': 'teststack%2Fabcd1234'}
        expect_args = ('POST',
                       '/stacks/teststack%2Fabcd1234/actions')
        expect_kwargs = {'data': {'check': None}}

        manager = self._base_test(expect_args, expect_kwargs)
        manager.check(**fields)