Skip to content

Commit

Permalink
fix tests, better error handling in module
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Nov 23, 2024
1 parent 1e2d873 commit 01b2036
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions bbot/modules/output/rabbitmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,16 @@ async def handle_event(self, event):
event_data = json.dumps(event_json).encode("utf-8")

# Publish the message to the queue
await self.channel.default_exchange.publish(
aio_pika.Message(body=event_data),
routing_key=self.queue_name,
)
while 1:
try:
await self.channel.default_exchange.publish(
aio_pika.Message(body=event_data),
routing_key=self.queue_name,
)
break
except Exception as e:
self.error(f"Error publishing message to RabbitMQ: {e}, rerying...")
await self.helpers.sleep(1)

async def cleanup(self):
# Close the connection
Expand Down
2 changes: 1 addition & 1 deletion bbot/test/test_step_1/test_python_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def test_python_api_validation():
# normal module as output module
with pytest.raises(ValidationError) as error:
Scanner(output_modules=["robots"])
assert str(error.value) == 'Could not find output module "robots". Did you mean "web_report"?'
assert str(error.value) == 'Could not find output module "robots". Did you mean "rabbitmq"?'
# invalid preset type
with pytest.raises(ValidationError) as error:
Scanner(preset="asdf")
Expand Down

0 comments on commit 01b2036

Please sign in to comment.