Raises an error if the queue name is empty
If the queue name is empty, it does not send it to the server and raises an exception instead. closes bug: #1397177 Change-Id: I7742752c4bad0863d0eafa52cf4c7c89360cd108
This commit is contained in:
parent
09de9ee381
commit
964443d942
@ -13,6 +13,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
from zaqarclient._i18n import _ # noqa
|
||||||
from zaqarclient import errors
|
from zaqarclient import errors
|
||||||
from zaqarclient.queues.v1 import claim as claim_api
|
from zaqarclient.queues.v1 import claim as claim_api
|
||||||
from zaqarclient.queues.v1 import core
|
from zaqarclient.queues.v1 import core
|
||||||
@ -25,6 +26,9 @@ class Queue(object):
|
|||||||
def __init__(self, client, name, auto_create=True):
|
def __init__(self, client, name, auto_create=True):
|
||||||
self.client = client
|
self.client = client
|
||||||
|
|
||||||
|
if name == "":
|
||||||
|
raise ValueError(_('Queue name does not have a value'))
|
||||||
|
|
||||||
# NOTE(flaper87) Queue Info
|
# NOTE(flaper87) Queue Info
|
||||||
self._name = name
|
self._name = name
|
||||||
self._metadata = None
|
self._metadata = None
|
||||||
|
@ -66,6 +66,9 @@ class QueuesV1QueueUnitTest(base.QueuesTestBase):
|
|||||||
# just checking our way down to the transport
|
# just checking our way down to the transport
|
||||||
# doesn't crash.
|
# doesn't crash.
|
||||||
|
|
||||||
|
def test_queue_valid_name(self):
|
||||||
|
self.assertRaises(ValueError, self.client.queue, "")
|
||||||
|
|
||||||
def test_queue_delete(self):
|
def test_queue_delete(self):
|
||||||
with mock.patch.object(self.transport, 'send',
|
with mock.patch.object(self.transport, 'send',
|
||||||
autospec=True) as send_method:
|
autospec=True) as send_method:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user