def testAddingHorseThrougQueue(self): # Create queue to receive response from receiver channel = self.connection.channel() isAdded = channel.queue_declare(exclusive=True) self.callback_queue = isAdded.method.queue channel.basic_consume( self._on_response, no_ack=True, queue=self.callback_queue ) self.isAdded = False # Send request through RabbitMQ to add a horse to test_database msg = TEST_HORSE + " " + TEST_DB # In props there is info on which queue to reply to props = pika.BasicProperties(reply_to=self.callback_queue) HorseSender.send_add_horse_request(msg, props) # Set timeout and wait for response self.connection.add_timeout(TIMEOUT, self._on_timeout) while not self.isAdded: self.connection.process_data_events() # Check if stormy is in the database self.is_horse_in_db(self.stormy)
def testColicMsg(self): # Find a horses id horses = self.client[TEST_DB].horses horse_id = horses.find_one({'Name': self.stormy['Name']})['_id'] # Send a msg that a horse has colic msg = str(horse_id) + " " + TEST_DB + " colic" HorseSender.send_emergency_msg(msg)