Ejemplo n.º 1
0
def on_request(ch, method, props, body):
    parametersList = RPCParameterHelper.splitParameters(body)

    print("A scraping request for %s has arrived" % parametersList[0])
    response = scrape(parametersList[0], parametersList[1])

    ch.basic_publish(exchange='',
                     routing_key=props.reply_to,
                     properties=pika.BasicProperties(correlation_id = \
                                                         props.correlation_id),
                     body=str(response))
    
    ch.basic_ack(delivery_tag = method.delivery_tag)
Ejemplo n.º 2
0
 def test_splitParametersShouldReturnAListOfLines(self):
     # try with a well-formed parameter setting
     self.assertEqual(RPCParameterHelper.splitParameters("ElMostrador&ElMostrador"), ['ElMostrador', 'ElMostrador'])
     # try with a bad parameter setting
     self.assertNotEqual(RPCParameterHelper.splitParameters("ElMostradorElMostrador"), ['ElMostrador', 'ElMostrador'])