@@ -0,0 +1,3155 @@
+# Licensed to the StackStorm, Inc ('StackStorm') under one or more%0A# contributor license agreements.  See the NOTICE file distributed with%0A# this work for additional information regarding copyright ownership.%0A# The ASF licenses this file to You under the Apache License, Version 2.0%0A# (the %22License%22); you may not use this file except in compliance with%0A# the License.  You may obtain a copy of the License at%0A#%0A#     http://www.apache.org/licenses/LICENSE-2.0%0A#%0A# Unless required by applicable law or agreed to in writing, software%0A# distributed under the License is distributed on an %22AS IS%22 BASIS,%0A# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A# See the License for the specific language governing permissions and%0A# limitations under the License.%0A%0Afrom st2common.service_setup import teardown as common_teardown%0Afrom st2common.service_setup import register_service_in_service_registry%0Afrom st2common.util import system_info%0Afrom st2common.services.coordination import get_member_id%0A%0Afrom st2tests import config as tests_config%0A%0Afrom tests.base import FunctionalTest%0A%0A__all__ = %5B%0A    'ServiceyRegistryControllerTestCase'%0A%5D%0A%0A%0Aclass ServiceyRegistryControllerTestCase(FunctionalTest):%0A%0A    @classmethod%0A    def setUpClass(cls):%0A        super(ServiceyRegistryControllerTestCase, cls).setUpClass()%0A%0A        tests_config.parse_args()%0A%0A        # NOTE: We mock call common_setup to emulate service being registered in the service%0A        # registry during bootstrap phase%0A        register_service_in_service_registry(service='mock_service',%0A                                             capabilities=%7B'key1': 'value1',%0A                                                           'name': 'mock_service'%7D,%0A                                             start_heart=True)%0A%0A    @classmethod%0A    def tearDownClass(cls):%0A        super(ServiceyRegistryControllerTestCase, cls).tearDownClass()%0A        common_teardown()%0A%0A    def test_get_groups(self):%0A        list_resp = self.app.get('/v1/service_registry/groups')%0A        self.assertEqual(list_resp.status_int, 200)%0A        self.assertEqual(list_resp.json, %7B'groups': %5B'mock_service'%5D%7D)%0A%0A    def test_get_group_members(self):%0A        proc_info = system_info.get_process_info()%0A        member_id = get_member_id()%0A%0A        # 1. Group doesn't exist%0A        resp = self.app.get('/v1/service_registry/groups/doesnt-exist/members', expect_errors=True)%0A        self.assertEqual(resp.status_int, 404)%0A        self.assertEqual(resp.json%5B'faultstring'%5D, 'Group with ID %22doesnt-exist%22 not found.')%0A%0A        # 2. Group exists and has a single member%0A        resp = self.app.get('/v1/service_registry/groups/mock_service/members')%0A        self.assertEqual(resp.status_int, 200)%0A        self.assertEqual(resp.json, %7B%0A            'members': %5B%0A                %7B%0A                    'member_id': member_id,%0A                    'capabilities': %7B%0A                        'key1': 'value1',%0A                        'name': 'mock_service',%0A                        'hostname': proc_info%5B'hostname'%5D,%0A                        'pid': proc_info%5B'pid'%5D%0A                    %7D%0A                %7D%0A            %5D%0A        %7D)%0A

Add test cases for new service registry related API endpoint.