-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for Celery/ServiceBus integration (#134)
* Add test for Celery/ServiceBus integration * Update to latest kombu version
- Loading branch information
Showing
4 changed files
with
41 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
azure-servicebus==0.21.1 # pyup: ignore | ||
azure-servicebus==0.50.0 | ||
gunicorn==19.9.0 | ||
tornado==5.1.1 |
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
Empty file.
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,39 @@ | ||
from os import getenv | ||
from random import choice | ||
from string import ascii_letters | ||
from unittest import TestCase | ||
from unittest import skipUnless | ||
|
||
from cached_property import cached_property | ||
from kombu import Connection | ||
from kombu import Exchange | ||
from kombu import Queue | ||
|
||
from opwen_email_server.config import QUEUE_BROKER | ||
|
||
|
||
class TransportTests(TestCase): | ||
exchange_name = getenv('KOMBU_EXCHANGE', 'testexchange') | ||
queue_name = getenv('KOMBU_QUEUE', 'testqueue') | ||
routing_key = getenv('KOMBU_ROUTING_KEY', 'testkey') | ||
|
||
@cached_property | ||
def exchange(self) -> Exchange: | ||
return Exchange(self.exchange_name, 'direct', durable=True) | ||
|
||
@cached_property | ||
def queue(self) -> Queue: | ||
return Queue(self.queue_name, exchange=self.exchange, | ||
routing_key=self.routing_key) | ||
|
||
@skipUnless(QUEUE_BROKER, 'no celery broker configured') | ||
def test_send_message(self): | ||
random_message = ''.join(choice(ascii_letters) # nosec | ||
for _ in range(30)) | ||
|
||
with Connection(QUEUE_BROKER) as connection: | ||
producer = connection.Producer() | ||
producer.publish({'message': random_message, 'test': True}, | ||
exchange=self.exchange, | ||
routing_key=self.routing_key, | ||
declare=[self.queue]) |