def test_get_all_consumer_groups(self, mock_collection, mock_resp): """ Test the consumer groups retrieval. """ consumer_mock = mock.MagicMock() resp = [{'id': 'foo', 'display_name': 'bar'}] consumer_mock.find.return_value = resp mock_collection.return_value = consumer_mock request = mock.MagicMock() consumer_group = ConsumerGroupView() response = consumer_group.get(request) expected_cont = [{'id': 'foo', 'display_name': 'bar', '_href': '/v2/consumer_groups/foo/'}] mock_resp.assert_called_once_with(expected_cont) self.assertTrue(response is mock_resp.return_value)