github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/acceptancetests/repository/trusty/haproxy/hooks/tests/test_upgrade_charm.py (about)

     1  from mock import patch
     2  from testtools import TestCase
     3  
     4  import hooks
     5  
     6  
     7  class UpgradeCharmTests(TestCase):
     8  
     9      def patch_hook(self, hook_name):
    10          mock_controller = patch.object(hooks, hook_name)
    11          mock = mock_controller.start()
    12          self.addCleanup(mock_controller.stop)
    13          return mock
    14  
    15      def test_calls_hooks(self):
    16          install_hook = self.patch_hook('install_hook')
    17          config_changed = self.patch_hook('config_changed')
    18          update_nrpe_config = self.patch_hook('update_nrpe_config')
    19          hooks.main('upgrade-charm')
    20          install_hook.assert_called_once_with()
    21          config_changed.assert_called_once_with()
    22          update_nrpe_config.assert_called_once_with()