Exemplo n.º 1
0
 def _verify_full_response(self, request, expected_response):
     request_proto = api_pb2.ListSessionGroupsRequest()
     text_format.Merge(request, request_proto)
     handler = list_session_groups.Handler(
         backend_context.Context(self._mock_tb_context), request_proto)
     response = handler.run()
     self.assertProtoEquals(expected_response, response)
Exemplo n.º 2
0
 def _verify_handler(self, request, expected_session_group_names,
                     expected_total_size):
     request_proto = api_pb2.ListSessionGroupsRequest()
     text_format.Merge(request, request_proto)
     handler = list_session_groups.Handler(
         backend_context.Context(self._mock_tb_context), request_proto)
     response = handler.run()
     self.assertEqual(expected_session_group_names,
                      [sg.name for sg in response.session_groups])
     self.assertEqual(expected_total_size, response.total_size)
Exemplo n.º 3
0
 def _run_handler(self, request):
     request_proto = api_pb2.ListSessionGroupsRequest()
     text_format.Merge(request, request_proto)
     handler = list_session_groups.Handler(
         backend_context.Context(self._mock_tb_context), request_proto)
     response = handler.run()
     # Sort the metric values repeated field in each session group to
     # canonicalize the response.
     for group in response.session_groups:
         group.metric_values.sort(key=operator.attrgetter("name.tag"))
     return response
Exemplo n.º 4
0
 def list_session_groups_route(self, request):
   try:
     _verify_request_is_post(request, '/session_groups')
     request_proto = json_format.Parse(request.data,
                                       api_pb2.ListSessionGroupsRequest())
     return http_util.Respond(
         request,
         json_format.MessageToJson(
             list_session_groups.Handler(self._context, request_proto).run(),
             including_default_value_fields=True,
         ),
         'application/json')
   except error.HParamsError as e:
     logger.error('HParams error: %s' % e)
     raise werkzeug.exceptions.BadRequest(description=str(e))
Exemplo n.º 5
0
 def list_session_groups_route(self, request):
     try:
         # args.get() returns the request unquoted.
         request_proto = request.args.get('request')
         if request_proto is None:
             raise error.HParamsError(
                 '/session_groups must have a \'request\' arg.')
         request_proto = json_format.Parse(
             request_proto, api_pb2.ListSessionGroupsRequest())
         return http_util.Respond(
             request,
             json_format.MessageToJson(
                 list_session_groups.Handler(self._context,
                                             request_proto).run()),
             'application/json')
     except error.HParamsError as e:
         raise werkzeug.exceptions.BadRequest(description=str(e))