def testLocalhost(self): @api_config.api(name='root', hostname='localhost:8080', version='v1', description='This is an API') class RootService(remote.Service): """Describes RootService.""" @api_config.method(message_types.VoidMessage, message_types.VoidMessage, path='foo', http_method='GET', name='foo') def foo(self, unused_request): """Blank endpoint.""" return message_types.VoidMessage() @api_config.api(name='myapi', hostname='localhost:8081', version='v1', description='This is my API') class MyService(remote.Service): """Describes MyService.""" @api_config.method(message_types.VoidMessage, message_types.VoidMessage, path='foo', http_method='GET', name='foo') def foo(self, unused_request): """Blank endpoint.""" return message_types.VoidMessage() api_server = apiserving.api_server([RootService, MyService]) api_config_response = api_server.get_api_configs() if api_config_response: api_server.config_manager.process_api_config_response(api_config_response) else: raise Exception('Could not process API config response') configs = [] for config in api_server.config_manager.configs.itervalues(): if config != API_CONFIG: configs.append(config) environ = test_util.create_fake_environ( 'http', 'localhost', path='/_ah/api/discovery/v1/apis') request = api_request.ApiRequest(environ, base_paths=['/_ah/api']) generator = directory_list_generator.DirectoryListGenerator(request) directory = json.loads(generator.pretty_print_config_to_json(configs)) try: pwd = os.path.dirname(os.path.realpath(__file__)) test_file = os.path.join(pwd, 'testdata', 'directory_list', 'localhost.json') with open(test_file) as f: expected_directory = json.loads(f.read()) except IOError as e: print 'Could not find expected output file ' + test_file raise e test_util.AssertDictEqual(expected_directory, directory, self)