mirror of https://github.com/celery/kombu.git
SQS: fix trimming .fifo from queue name (#982)
* SQS: fix trimming .fifo from queue name * add test * fix lint error
This commit is contained in:
parent
93a05f7261
commit
5ee7c1ddcc
|
@ -57,7 +57,7 @@ from . import virtual
|
|||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
# dots are replaced by dash, all other punctuation
|
||||
# dots are replaced by dash, dash remains dash, all other punctuation
|
||||
# replaced by underscore.
|
||||
CHARS_REPLACE_TABLE = {
|
||||
ord(c): 0x5f for c in string.punctuation if c not in '-_.'
|
||||
|
@ -151,7 +151,7 @@ class Channel(virtual.Channel):
|
|||
def entity_name(self, name, table=CHARS_REPLACE_TABLE):
|
||||
"""Format AMQP queue name into a legal SQS queue name."""
|
||||
if name.endswith('.fifo'):
|
||||
partial = name.rstrip('.fifo')
|
||||
partial = name[:-len('.fifo')]
|
||||
partial = text_t(safe_str(partial)).translate(table)
|
||||
return partial + '.fifo'
|
||||
else:
|
||||
|
|
|
@ -224,6 +224,12 @@ class test_Channel:
|
|||
conn = Connection(hostname=None, transport=SQS.Transport)
|
||||
assert conn.hostname == conn.clone().hostname
|
||||
|
||||
def test_entity_name(self):
|
||||
assert self.channel.entity_name('foo') == 'foo'
|
||||
assert self.channel.entity_name('foo.bar-baz*qux_quux') == \
|
||||
'foo-bar-baz_qux_quux'
|
||||
assert self.channel.entity_name('abcdef.fifo') == 'abcdef.fifo'
|
||||
|
||||
def test_new_queue(self):
|
||||
queue_name = 'new_unittest_queue'
|
||||
self.channel._new_queue(queue_name)
|
||||
|
|
Loading…
Reference in New Issue