Skip to content

Commit

Permalink
feat: changing some env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
AyronFelipe committed Jan 9, 2023
1 parent ff43756 commit b480e8b
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 26 deletions.
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ Now you must provide broker connection details filling out the following paramet
- STOMP_SERVER_HOST
- STOMP_SERVER_PORT
- STOMP_USE_SSL
- STOMP_HOST_AND_PORTS

And just create the job issuing the following command:

Expand Down Expand Up @@ -157,13 +156,6 @@ defined, this parameter **must** be an integer!

  Optional parameter that controls how many seconds django-stomp will wait for a message to be processed. Defaults to 30 seconds. If defined, this parameter **must** be an integer!

***STOMP_HOST_AND_PORTS***

  Optional parameter to set the value of the HOST and PORT of your STOMP server. Must be in the following format:
```python
STOMP_HOST_AND_PORTS=[("127.0.0.1", 61631)] # your HOST and your PORT respectively
```

## Tests

In order to execute tests for ActiveMQ, execute the following:
Expand Down
8 changes: 1 addition & 7 deletions django_stomp/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import tenacity
from stomp.connect import StompConnection11

from django_stomp.exceptions import DjangoStompImproperlyConfigured

logger = logging.getLogger("django_stomp")


Expand Down Expand Up @@ -56,7 +54,7 @@ def eval_as_int_otherwise_none(value):
def only_destination_name(destination: str) -> str:
position = destination.rfind("/")
if position > 0:
return destination[position + 1 :]
return destination[position + 1 :] # noqa: E203
return destination


Expand Down Expand Up @@ -126,10 +124,6 @@ def set_ssl_connection(conn: StompConnection11) -> StompConnection11:
from django_stomp import settings

host_and_ports = settings.STOMP_HOST_AND_PORTS
if not host_and_ports:
error_message = "The value of the environment variable STOMP_HOST_AND_PORTS are not set"
logger.error(error_message)
raise DjangoStompImproperlyConfigured(error_message)
key_file = settings.DEFAULT_STOMP_KEY_FILE
cert_file = settings.DEFAULT_STOMP_CERT_FILE
ca_certs = settings.DEFAULT_STOMP_CA_CERTS
Expand Down
4 changes: 2 additions & 2 deletions django_stomp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def eval_settings_otherwise_raise_exception(
STOMP_SERVER_PORT = eval_as_int_if_provided_value_is_not_none_otherwise_none(
getattr(django_settings, "STOMP_SERVER_PORT", 61613)
)
STOMP_USE_SSL = eval_str_as_boolean(os.getenv("STOMP_USE_SSL"))
STOMP_HOST_AND_PORTS = os.getenv("STOMP_HOST_AND_PORTS", [(STOMP_SERVER_HOST, STOMP_SERVER_PORT)])
STOMP_USE_SSL = eval_str_as_boolean(os.getenv("STOMP_USE_SSL", False))
STOMP_HOST_AND_PORTS = [(STOMP_SERVER_HOST, STOMP_SERVER_PORT)]
DEFAULT_SSL_VERSION = os.getenv("DEFAULT_SSL_VERSION")
DEFAULT_STOMP_KEY_FILE = os.getenv("DEFAULT_STOMP_KEY_FILE")
DEFAULT_STOMP_CERT_FILE = os.getenv("DEFAULT_STOMP_CERT_FILE")
Expand Down
9 changes: 0 additions & 9 deletions tests/unit/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from pytest_mock import MockerFixture
from stomp.connect import StompConnection11

from django_stomp.exceptions import DjangoStompImproperlyConfigured
from django_stomp.helpers import retry
from django_stomp.helpers import set_ssl_connection

Expand All @@ -28,14 +27,6 @@ def raise_exception():
assert all([log.levelname == "WARNING" for log in tenacity_logs])


def test_should_raise_django_stomp_improperly_configured_exception_when_env_var_is_not_set(mocker: MockerFixture):
mocked_settings = mocker.patch("django_stomp.settings")
mocked_settings.STOMP_HOST_AND_PORTS = None
with pytest.raises(DjangoStompImproperlyConfigured):
connection = StompConnection11()
set_ssl_connection(conn=connection)


def test_should_create_a_connection_with_success_when_and_return_it(mocker: MockerFixture):
mocked_settings = mocker.patch("django_stomp.settings")
mocked_settings.STOMP_HOST_AND_PORTS = ["127.0.0.1"]
Expand Down

0 comments on commit b480e8b

Please sign in to comment.