Add unit tests for assess status

This commit is contained in:
James Page 2015-10-08 04:52:56 -07:00
parent f2ce96516c
commit dcb800d1b4

View File

@ -11,7 +11,10 @@ TO_PATCH = ['log', 'config',
'relation_set', 'relation_set',
'update_nrpe_config', 'update_nrpe_config',
'get_iface_for_address', 'get_iface_for_address',
'get_netmask_for_address'] 'get_netmask_for_address',
'cluster_in_sync',
'is_bootstrapped',
'status_set']
class TestHaRelation(CharmTestCase): class TestHaRelation(CharmTestCase):
@ -127,3 +130,25 @@ class TestHaRelation(CharmTestCase):
call_args, call_kwargs = self.relation_set.call_args call_args, call_kwargs = self.relation_set.call_args
self.assertEqual(resource_params, call_kwargs['resource_params']) self.assertEqual(resource_params, call_kwargs['resource_params'])
class TestAssessStatus(CharmTestCase):
def setUp(self):
CharmTestCase.setUp(self, hooks, TO_PATCH)
def test_not_bootstrapped(self):
self.is_bootstrapped.return_value = False
hooks.assess_status()
self.status_set.assert_called_with('blocked', mock.ANY)
def test_bootstrapped_in_sync(self):
self.is_bootstrapped.return_value = True
self.cluster_in_sync.return_value = True
hooks.assess_status()
self.status_set.assert_called_with('active', mock.ANY)
def test_bootstrapped_not_in_sync(self):
self.is_bootstrapped.return_value = True
self.cluster_in_sync.return_value = False
hooks.assess_status()
self.status_set.assert_called_with('blocked', mock.ANY)