def test__get_broker_rid_unit_for_previous_request_not_found( self, get_previous_request, get_broker_rsp_key): request = hooks.CephBrokerRq() get_broker_rsp_key.return_value = "my_key" get_previous_request.return_value = request self.relation_ids.return_value = ['ceph:43'] self.related_units.return_value = ['ceph-mon/0', 'ceph-mon/1'] self.relation_get.side_effect = [{}, {}] rid, unit = hooks._get_broker_rid_unit_for_previous_request() get_previous_request.assert_called_once_with('ceph:43') get_broker_rsp_key.assert_called_once_with() self.relation_get.assert_has_calls = [ call(rid='ceph:43', unit='ceph-mon/0'), call(rid='ceph:43', unit='ceph-mon/1') ] self.assertIsNone(unit) self.assertIsNone(rid)
def test__get_broker_rid_unit_for_previous_request( self, get_previous_request, get_broker_rsp_key): request = hooks.CephBrokerRq() get_broker_rsp_key.return_value = "my_key" get_previous_request.return_value = request self.relation_ids.return_value = ['ceph:43'] self.related_units.return_value = ['ceph-mon/0', 'ceph-mon/1'] self.relation_get.side_effect = [{}, { 'my_key': '{"api-version": 1, "ops": [], ' '"request-id": "' + request.request_id + '"}' }] rid, unit = hooks._get_broker_rid_unit_for_previous_request() get_previous_request.assert_called_once_with('ceph:43') get_broker_rsp_key.assert_called_once_with() self.relation_get.assert_has_calls = [ call(rid='ceph:43', unit='ceph-mon/0'), call(rid='ceph:43', unit='ceph-mon/1') ] self.assertEqual('ceph-mon/1', unit) self.assertEqual('ceph:43', rid)