This file is indexed.

/usr/lib/python2.7/dist-packages/charmtools/templates/ansible/files/unit_tests/test_hooks.py is in charm-tools 2.1.2-0ubuntu4.

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
import unittest

try:
    import mock
except ImportError:
    raise ImportError(
        "Please ensure both python-mock and python-nose are installed.")


from hooks import hooks


class InstallHookTestCase(unittest.TestCase):

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

        patcher = mock.patch('hooks.charmhelpers')
        self.mock_charmhelpers = patcher.start()
        self.addCleanup(patcher.stop)
        self.mock_charmhelpers.core.hookenv.config.return_value = {
            'install_deps_from_ppa': False,
        }

        patcher = mock.patch('charmhelpers.contrib.ansible.apply_playbook')
        self.mock_apply_playbook = patcher.start()
        self.addCleanup(patcher.stop)

    def test_installs_ansible_support(self):
        hooks.execute(['install'])

        ansible = self.mock_charmhelpers.contrib.ansible
        ansible.install_ansible_support.assert_called_once_with(
            from_ppa=True)

    def test_applies_install_playbook(self):
        hooks.execute(['install'])

        self.assertEqual([
            mock.call('playbooks/site.yaml', tags=['install']),
        ], self.mock_apply_playbook.call_args_list)


class DefaultHooksTestCase(unittest.TestCase):

    def setUp(self):
        super(DefaultHooksTestCase, self).setUp()
        patcher = mock.patch('charmhelpers.contrib.ansible.apply_playbook')
        self.mock_apply_playbook = patcher.start()
        self.addCleanup(patcher.stop)

    def test_default_hooks(self):
        """Most of the hooks let ansible do all the work."""
        for hook in ('start', 'stop', 'config-changed'):
            self.mock_apply_playbook.reset_mock()

            hooks.execute([hook])

            self.assertEqual([
                mock.call('playbooks/site.yaml',
                          tags=[hook]),
            ], self.mock_apply_playbook.call_args_list)