added unit test

This commit is contained in:
Edward Hope-Morley 2015-04-20 09:19:08 +01:00
parent 7ab0a3524f
commit 0355884f35
2 changed files with 18 additions and 1 deletions

View File

@ -171,4 +171,4 @@ options:
default:
description: |
Minimum number of units expected to exist before charm will attempt to
form a cluster.
form a rabbitmq cluster.

View File

@ -129,3 +129,20 @@ class RelationUtil(TestCase):
mock_peer_store_and_set.assert_called_with(
relation_settings={'private-address': ipv6_addr},
relation_id=None)
@patch.object(rabbitmq_server_relations, 'related_units')
@patch.object(rabbitmq_server_relations, 'relation_ids')
@patch.object(rabbitmq_server_relations, 'config')
def test_is_sufficient_peers(self, mock_config, mock_relation_ids,
mock_related_units):
_config = {'min-cluster-size': None}
mock_config.side_effect = lambda key: _config.get(key)
self.assertTrue(rabbitmq_server_relations.is_sufficient_peers())
mock_relation_ids.return_value = ['cluster:0']
mock_related_units.return_value = ['test/0']
_config = {'min-cluster-size': 3}
self.assertFalse(rabbitmq_server_relations.is_sufficient_peers())
mock_related_units.return_value = ['test/0', 'test/1']
self.assertTrue(rabbitmq_server_relations.is_sufficient_peers())