Esempio n. 1
0
 def test_valid_from_bson_construction(self):
     request = {
         'headers': [],
         'method': 'method',
         'path': 'path',
         'body': {}
     }
     valid_msg = BSON.encode(request)
     r = Request.from_bson(valid_msg)
     self.assertEqual(request['headers'], r.headers)
     self.assertEqual(request['method'], r.method)
     self.assertEqual(request['path'], r.path)
     self.assertEqual(request['body'], r.body)
Esempio n. 2
0
 def run(self):
     context = zmq.Context()
 
     server = context.socket(zmq.REP)
     server.bind("tcp://*:5555")
     while True:
         raw_request = server.recv()
         try:
             request = Request.from_raw(raw_request)
             # do some dispatching shizzle
             response = ErrorResponse("Fo' shizzle")
         except:
             response = ErrorResponse('Fatal error')
 
         server.send(response.bson)