Exemplo n.º 1
0
  def DoRequest(self,
                path,
                request,
                response_type,
                reg_path='/protorpc'):
    stdin = sys.stdin
    stdout = sys.stdout
    environ = os.environ
    try:
      sys.stdin = cStringIO.StringIO(protojson.encode_message(request))
      sys.stdout = cStringIO.StringIO()

      os.environ = webapp_test_util.GetDefaultEnvironment()
      os.environ['PATH_INFO'] = path
      os.environ['REQUEST_METHOD'] = 'POST'
      os.environ['CONTENT_TYPE'] = 'application/json'
      os.environ['wsgi.input'] = sys.stdin
      os.environ['wsgi.output'] = sys.stdout
      os.environ['CONTENT_LENGTH'] = len(sys.stdin.getvalue())

      service_handlers.run_services(
        [('/my_service', GetCalled.new_factory(self))], reg_path)

      header, body = sys.stdout.getvalue().split('\n\n', 1)

      return (header.split('\n')[0],
              protojson.decode_message(response_type, body))
    finally:
      sys.stdin = stdin
      sys.stdout = stdout
      os.environ = environ
Exemplo n.º 2
0
def main():
    service_handlers.run_services([
        ('/music', tunes_db.MusicLibraryService),
    ])
Exemplo n.º 3
0
def main():
  service_handlers.run_services(
    [('/music', tunes_db.MusicLibraryService),
    ])
Exemplo n.º 4
0
def main():
  service_handlers.run_services(
    [('/echo', EchoService),
    ])
Exemplo n.º 5
0
def main():
  service_handlers.run_services([('/hello', HelloService)])
Exemplo n.º 6
0
def main():
  service_handlers.run_services(
    [('/echo', EchoService),
    ])