Commit 3b8f304c authored by lukas.burgey's avatar lukas.burgey
Browse files

Add the NO_BROKER setting

If this is set to True the broker will stop publishing.
This is used when running CI tests
parent 7965cc61
......@@ -3,6 +3,7 @@ from logging import getLogger
from pika import BlockingConnection, ConnectionParameters, BasicProperties
from pika.credentials import PlainCredentials
from django.conf import settings
LOGGER = getLogger(__name__)
......@@ -64,6 +65,10 @@ class RabbitMQInstance:
raise e
def _publish(self, exchange, routing_key, body):
# when running CI tests we have no broker, so just do nothing
if getattr(settings, 'NO_BROKER', False):
return
connection = self._open_connection()
channel = connection.channel()
......@@ -86,6 +91,10 @@ class RabbitMQInstance:
# called on client registration to make sure the exchanges exists
def initialize(self):
# when running CI tests we have no broker, so just do nothing
if getattr(settings, 'NO_BROKER', False):
return
connection = self._open_connection()
channel = connection.channel()
self._init_exchanges(channel)
......
import os
import sys
# only set in docker_settings.py
NO_BROKER = True
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment