118
118
self.assertIn('python-pyramid', pkgs)
121
class TestConfigHooks(RestishTestCase):
123
super(TestConfigHooks, self).setUp()
125
m = mock.patch('hooks._wsgi_reload')
126
self.wsgi_reload = m.start()
127
self.addCleanup(m.stop)
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)
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')
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'])
121
154
class TestIntercomHooks(RestishTestCase):
123
156
def get_intercom_content(self):