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:
dynarro 2015-03-25 18:11:29 +01:00
parent 09de9ee381
commit 964443d942
2 changed files with 7 additions and 0 deletions

View File

@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from zaqarclient._i18n import _ # noqa
from zaqarclient import errors
from zaqarclient.queues.v1 import claim as claim_api
from zaqarclient.queues.v1 import core
@ -25,6 +26,9 @@ class Queue(object):
def __init__(self, client, name, auto_create=True):
self.client = client
if name == "":
raise ValueError(_('Queue name does not have a value'))
# NOTE(flaper87) Queue Info
self._name = name
self._metadata = None

View File

@ -66,6 +66,9 @@ class QueuesV1QueueUnitTest(base.QueuesTestBase):
# just checking our way down to the transport
# doesn't crash.
def test_queue_valid_name(self):
self.assertRaises(ValueError, self.client.queue, "")
def test_queue_delete(self):
with mock.patch.object(self.transport, 'send',
autospec=True) as send_method: