Esempio n. 1
0
   def deploy_handler(err, id):
       if err is None:
   #        import static_data
           print "loaded " + id
           def bla(reply,r2): print 'bla',reply,r2
           EventBus.send_with_timeout("campudus.jsonvalidator", {
 "action" : "addSchema",
 "key" : "simpleAddSchema",
 "jsonSchema" : {
   "$schema": "http://json-schema.org/draft-04/schema#",
   "title": "Example Schema",
   "type": "object",
   "properties": {
     "firstName": {
       "type": "string"
     },
     "lastName": {
       "type": "string"
     },
       "age": {
         "description": "Age in years",
         "type": "integer",
         "minimum": 0
       }
     },
     "required": ["firstName", "lastName"]
   }
   }, 1000, bla)
           EventBus.send("campudus.jsonvalidator", {"action":"getSchemaKeys"}, bla)
       else:
           print 'Failed to deploy %s' % err
           err.printStackTrace()
    def test_reply_timeout(self):
        json = {'message': 'hello world!'}
        address = 'some-address'
        reply = {'cheese': 'stilton!'}
        def handler(msg):
            tu.azzert(msg.body['message'] == json['message'])
        id = EventBus.register_handler(address, handler=handler)
        tu.azzert(id != None)

        def reply_handler(error, msg):
            tu.azzert(error != None)
            EventBus.unregister_handler(id)
            tu.test_complete()
        EventBus.send_with_timeout(address, json, 10, reply_handler)
    def test_reply_timeout(self):
        json = {'message': 'hello world!'}
        address = 'some-address'
        reply = {'cheese': 'stilton!'}

        def handler(msg):
            tu.azzert(msg.body['message'] == json['message'])

        id = EventBus.register_handler(address, handler=handler)
        tu.azzert(id != None)

        def reply_handler(error, msg):
            tu.azzert(error != None)
            EventBus.unregister_handler(id)
            tu.test_complete()

        EventBus.send_with_timeout(address, json, 10, reply_handler)