Skip to content

Commit

Permalink
Merge branch 'master' into feature/dont-try-parse-body
Browse files Browse the repository at this point in the history
  • Loading branch information
dmvieira committed May 14, 2020
2 parents c2c69af + a840d12 commit 090c47f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ setup: install
@pip install -r requirements/requirements_test.txt

lint:
@flake8 barterdude tests tests_integration
@flake8 barterdude tests_unit tests_integration

test:
@nosetests -s --exclude="tests_integration" --with-coverage --cover-erase --cover-package=barterdude
Expand Down
2 changes: 1 addition & 1 deletion barterdude/hooks/metrics/prometheus/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def _prepare_on_connection_fail(
self, state: str, namespace: str, unit: str):

self.__metrics[state] = Counter(
name=f"connection_fail",
name="connection_fail",
documentation=("Number of times barterdude failed "
"to connect to the AMQP broker"),
labelnames=self.__labelkeys,
Expand Down
4 changes: 4 additions & 0 deletions barterdude/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def body(self):
def raw(self):
return self._message.serialized_data

@property
def queue_name(self):
return self._message._amqp_message.queue_name

@property
def properties(self):
return self._message._amqp_message._properties
Expand Down
5 changes: 3 additions & 2 deletions tests_integration/test_rabbitmq_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ async def test_process_messages_successfully_even_with_crashed_hook(self):
received_messages = set()

monitor = Monitor(ErrorHook())
@self.app.consume_amqp([self.input_queue], coroutines=1,
monitor=monitor)

@self.app.consume_amqp(
[self.input_queue], coroutines=1, monitor=monitor)
async def handler(message):
nonlocal received_messages
received_messages.add(message.body["key"])
Expand Down
2 changes: 2 additions & 0 deletions tests_unit/test_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def test_should_convert_rabbitmq_message_to_message(self):
self.assertEqual(message.body, rbmq_message.body)
self.assertEqual(
message.properties, rbmq_message._amqp_message._properties)
self.assertEqual(
message.queue_name, rbmq_message._amqp_message.queue_name)
self.assertEqual(message.raw, rbmq_message.serialized_data)

async def test_should_call_rbmq_methods(self):
Expand Down

0 comments on commit 090c47f

Please sign in to comment.