~cprov/uci-engine/tarmac-multienv

« back to all changes in this revision

Viewing changes to charms/precise/restish/unit_tests/test_hooks.py

  • Committer: Evan Dandrea
  • Date: 2014-06-30 12:07:54 UTC
  • mfrom: (630 uci-engine)
  • mto: This revision was merged to the branch mainline in revision 655.
  • Revision ID: evan.dandrea@canonical.com-20140630120754-z6x5eqdahpp2qfrt
Merge with trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
118
118
        self.assertIn('python-pyramid', pkgs)
119
119
 
120
120
 
 
121
class TestConfigHooks(RestishTestCase):
 
122
    def setUp(self):
 
123
        super(TestConfigHooks, self).setUp()
 
124
 
 
125
        m = mock.patch('hooks._wsgi_reload')
 
126
        self.wsgi_reload = m.start()
 
127
        self.addCleanup(m.stop)
 
128
 
 
129
    @mock.patch('os.symlink')
 
130
    @mock.patch('os.unlink')
 
131
    def test_cron_unconfigured(self, unlink, symlink):
 
132
        mock.patch('hooks.update_nrpe_config').start()
 
133
        hooks.execute(['hooks/config-changed'])
 
134
        self.assertEqual(0, symlink.call_count)
 
135
        self.assertEqual(0, unlink.call_count)
 
136
 
 
137
    @mock.patch('os.symlink')
 
138
    @mock.patch('os.unlink')
 
139
    def test_cron_good(self, unlink, symlink):
 
140
        self.config.return_value['cron_period'] = 'daily'
 
141
        self.config.return_value['cron_cmd'] = 'foo.sh'
 
142
        mock.patch('hooks.update_nrpe_config').start()
 
143
        hooks.execute(['hooks/config-changed'])
 
144
        self.assertEqual(0, unlink.call_count)
 
145
        symlink.assert_called_once_with(
 
146
            '/srv/local-test/foo.sh', '/etc/cron.daily/local-test')
 
147
 
 
148
    def test_cron_bad(self):
 
149
        self.config.return_value['cron_period'] = 'invalid'
 
150
        with self.assertRaises(ValueError):
 
151
            hooks.execute(['hooks/config-changed'])
 
152
 
 
153
 
121
154
class TestIntercomHooks(RestishTestCase):
122
155
 
123
156
    def get_intercom_content(self):