-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid deploying misconfigured messaging plugin
Initializes messaging plugin at start which would effectively cancel deployment of a broken app.
- Loading branch information
Showing
5 changed files
with
72 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from unittest.mock import Mock | ||
|
||
from pytest import raises | ||
|
||
from resultsdb import setup_messaging | ||
|
||
|
||
def test_app_messaging(app): | ||
assert app.messaging_plugin is not None | ||
assert type(app.messaging_plugin).__name__ == "DummyPlugin" | ||
|
||
|
||
def test_app_messaging_none(): | ||
app = Mock() | ||
app.config = {"MESSAGE_BUS_PUBLISH": False} | ||
setup_messaging(app) | ||
app.logger.info.assert_called_once_with("No messaging plugin") | ||
|
||
|
||
def test_app_messaging_stomp(): | ||
app = Mock() | ||
app.config = { | ||
"MESSAGE_BUS_PUBLISH": True, | ||
"MESSAGE_BUS_PLUGIN": "stomp", | ||
"MESSAGE_BUS_KWARGS": { | ||
"destination": "results.new", | ||
"connection": { | ||
"host_and_ports": [("localhost", 1234)], | ||
}, | ||
}, | ||
} | ||
setup_messaging(app) | ||
app.logger.info.assert_called_once_with("Using messaging plugin %s", "stomp") | ||
|
||
|
||
def test_app_messaging_stomp_bad(): | ||
app = Mock() | ||
app.config = { | ||
"MESSAGE_BUS_PUBLISH": True, | ||
"MESSAGE_BUS_PLUGIN": "stomp", | ||
"MESSAGE_BUS_KWARGS": { | ||
"connection": { | ||
"host_and_ports": [("localhost", 1234)], | ||
}, | ||
}, | ||
} | ||
expected_error = "Missing 'destination' option for STOMP messaging plugin" | ||
with raises(ValueError, match=expected_error): | ||
setup_messaging(app) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters