~sidnei/charms/precise/haproxy/trunk

« back to all changes in this revision

Viewing changes to hooks/tests/test_config_changed_hooks.py

  • Committer: Liam young
  • Date: 2013-06-03 14:00:56 UTC
  • mfrom: (71.3.55 master)
  • Revision ID: liam.young@canonical.com-20130603140056-gbzj7lh2f1vdczrr
Fixes and test updates from ubuntuone-pqm-team

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import sys
 
2
 
1
3
from testtools import TestCase
2
4
from mock import patch
3
5
 
23
25
            "construct_haproxy_config")
24
26
        self.service_haproxy = self.patch_hook(
25
27
            "service_haproxy")
 
28
        self.update_sysctl = self.patch_hook(
 
29
            "update_sysctl")
26
30
        self.notify_website = self.patch_hook("notify_website")
27
31
        self.notify_peer = self.patch_hook("notify_peer")
 
32
        self.log = self.patch_hook("log")
 
33
        sys_exit = patch.object(sys, "exit")
 
34
        self.sys_exit = sys_exit.start()
 
35
        self.addCleanup(sys_exit.stop)
28
36
 
29
37
    def patch_hook(self, hook_name):
30
38
        mock_controller = patch.object(hooks, hook_name)
66
74
 
67
75
        self.notify_website.assert_not_called()
68
76
        self.notify_peer.assert_not_called()
 
77
        self.log.assert_called_once_with(
 
78
            "HAProxy configuration check failed, exiting.")
 
79
        self.sys_exit.assert_called_once_with(1)
69
80
 
70
81
 
71
82
class HelpersTest(TestCase):