Пример #1
0
def test_pyro():
    from automaton.server.pyro import PyroServer
    import automaton.client.pyro as pyro

    print "Starting Pyro Server"

    server = PyroServer(port=9092)
    server.initialize()

    thread = threading.Thread(target=server.start)
    thread.daemon = True
    thread.start()
    time.sleep(3)  # wait for server to initialize

    try:
        client = pyro.ClientWrapper(appname="testharness", port=9092)
        client.open()

        print "Starting Pyro Testing..."

        test_client(client)

        client.close()

    except pyro.ClientException as tx:
        print "Client exception encountered: " + tx.message

    server.daemon.shutdown()
Пример #2
0
def test_pyro():
    from automaton.server.pyro import PyroServer
    import automaton.client.pyro as pyro

    print "Starting Pyro Server"

    server = PyroServer(port=9092)
    server.initialize()

    thread = threading.Thread(target=server.start)
    thread.daemon = True
    thread.start()
    time.sleep(3)  # wait for server to initialize

    try:
        client = pyro.ClientWrapper(appname="testharness", port=9092)
        client.open()

        print "Starting Pyro Testing..."

        test_client(client)

        client.close()

    except pyro.ClientException as tx:
        print 'Client exception encountered: ' + tx.message

    server.daemon.shutdown()
Пример #3
0
def test_server():
  from automaton.server.pyro import PyroServer
  import automaton.client.pyro as pyro

  print "Starting test server"

  server = PyroServer(port = 9090)
  server.initialize()

  thread = threading.Thread(target=server.start)
  thread.daemon = True
  thread.start()
  time.sleep(3) # wait for server to initialize

  success = set()
  failure = {}

  try:
    client = pyro.ClientWrapper(appname="testharness",port=9090)

    test = "interpreting without registering"
    try:
      client.interpret("echo hello")
      failure[test] = "Requesting service should fail."
    except exceptions.ClientNotRegisteredError:
      success.add(test)
    client.open()

    print "Starting server Testing..."

    test = "serviceNotProvidedError"
    try:
      try:
        client.allowService("asdkjhasdkjh")
        failure[test] = "somehow registered service with random name..."
      except exceptions.ServiceNotProvidedError:
        success.add(test)
    except Exception as e:
      failure[test] = "Unknown exception encountered: " + e

    test = "allowAllServices"
    try:
      client.allowAllServices()
      try:
        client.interpret("echo hello")
        success.add(test)
      except exceptions.ServiceNotRegisteredError:
        failure[test] = "allowAllServices did not enable echo service"
    except Exception as e:
      failure[test] = "Unknown exception encountered: " + e

    test = "disallowService"
    try:
      client.disallowService("echo")
      try:
        client.interpret("echo hello")
        failure[test] = "disallowService did not disable echo service"
      except exceptions.ServiceNotRegisteredError:
        success.add(test)
    except Exception as e:
      failure[test] = "Unknown exception encountered: " + e

    test = "allowService"
    try:
      client.allowService("echo")
      try:
        client.interpret("echo hello")
        success.add(test)
      except exceptions.ServiceNotRegisteredError:
        failure[test] = "allowService did not enable echo service"
    except Exception as e:
      failure[test] = "Unknown exception encountered: " + e
    
    test = "isService"
    try:
      if client.isService("echo"):
        success.add(test)
      else:
        failure[test] = "Failed to determine echo as a service"
    except Exception as e:
      failure[test] = "Unknown exception encountered: " + e

    test = "getAvailableServices"
    try:
      if len(client.getAvailableServices()) > 0:
        success.add(test)
      else:
        failure[test] = "No available services"
    except Exception as e:
      failure[test] = "Unknown exception encountered: " + e


    if len(success) > 0:
      print "Successful execution for:"
      for script in success:
        print " ", script

    if len(failure) > 0:
      print
      print "Failed execution for:"
      for key in failure:
        print " ", key, ":", failure[key]

    client.close()

  except pyro.ClientException as tx:
    print 'Client exception encountered: ' + tx.message

  server.daemon.shutdown()



  client.close()

  except pyro.ClientException as tx:
    print 'Client exception encountered: ' + tx.message