# Path: zaqarclient/queues/client.py
# _CLIENTS = {1: cv1.Client,
#             1.1: cv1.Client,
#             2: cv2.Client}
# def Client(url=None, version=None, conf=None, session=None):
# 
# Path: zaqarclient/queues/v1/core.py
# def _common_queue_ops(operation, transport, request, name, callback=None):
# def queue_create(transport, request, name,
#                  metadata=None, callback=None):
# def queue_update(transport, request, name, metadata, callback=None):
# def queue_exists(transport, request, name, callback=None):
# def queue_get(transport, request, name, callback=None):
# def queue_get_metadata(transport, request, name, callback=None):
# def queue_set_metadata(transport, request, name, metadata, callback=None):
# def queue_get_stats(transport, request, name):
# def queue_delete(transport, request, name, callback=None):
# def queue_list(transport, request, callback=None, **kwargs):
# def message_list(transport, request, queue_name, callback=None, **kwargs):
# def message_post(transport, request, queue_name, messages, callback=None):
# def message_get(transport, request, queue_name, message_id, callback=None):
# def message_get_many(transport, request, queue_name, messages, callback=None):
# def message_delete(transport, request, queue_name, message_id,
#                    claim_id=None, callback=None):
# def message_delete_many(transport, request, queue_name,
#                         ids, callback=None):
# def message_pop(transport, request, queue_name,
#                 count, callback=None):
# def claim_create(transport, request, queue_name, **kwargs):
# def claim_get(transport, request, queue_name, claim_id):
# def claim_update(transport, request, queue_name, claim_id, **kwargs):
# def claim_delete(transport, request, queue_name, claim_id):
# def pool_get(transport, request, pool_name, callback=None):
# def pool_create(transport, request, pool_name, pool_data):
# def pool_update(transport, request, pool_name, pool_data):
# def pool_list(transport, request, **kwargs):
# def pool_delete(transport, request, pool_name):
# def flavor_create(transport, request, name, flavor_data):
# def flavor_get(transport, request, flavor_name, callback=None):
# def flavor_update(transport, request, flavor_name, flavor_data):
# def flavor_list(transport, request, **kwargs):
# def flavor_delete(transport, request, name):
# def health(transport, request, callback=None):
# 
# Path: zaqarclient/tests/base.py
# _USE_AUTHENTICATION = os.environ.get('ZAQARCLIENT_AUTH_FUNCTIONAL', False)
# _RUN_FUNCTIONAL = os.environ.get('ZAQARCLIENT_TEST_FUNCTIONAL',
#                                  _USE_AUTHENTICATION)
# class TestBase(testtools.TestCase):
#     def setUp(self):
#     def _credentials(self, cloud='devstack-admin'):
#     def _setup_auth_params(self):
#     def config(self, group=None, **kw):
# 
# Path: zaqarclient/transport/errors.py
# class TransportError(errors.ZaqarError):
# class ResourceNotFound(TransportError):
# class MalformedRequest(TransportError):
# class UnauthorizedError(TransportError):
# class ForbiddenError(TransportError):
# class InternalServerError(TransportError):
# class ServiceUnavailableError(TransportError):
# class ConflictError(TransportError):
#     def __init__(self, title=None, description=None, text=None):


import mock
import ddt
from zaqarclient.queues import client
from zaqarclient.queues.v1 import core
from zaqarclient.tests import base
from zaqarclient.transport import errors


VERSIONS = [1, 1.1]


@ddt.ddt
class TestClient(base.TestBase):

    @ddt.data(*VERSIONS)
    def test_transport(self, version):
        cli = client.Client('http://example.com',
                            version, {"auth_opts": {'backend': 'noauth'}})
        self.assertIsNotNone(cli.transport())

    @ddt.data(*VERSIONS)
    def test_health_ok(self, version):
        cli = client.Client('http://example.com',
                            version, {"auth_opts": {'backend': 'noauth'}})
        with mock.patch.object(core, 'health', autospec=True) as core_health:
            core_health.return_value = None
            self.assertTrue(cli.health())

    @ddt.data(*VERSIONS)
    def test_health_bad(self, version):
        cli = client.Client('http://example.com',
                            version, {"auth_opts": {'backend': 'noauth'}})

        def raise_error(*args, **kwargs):
            raise errors.ServiceUnavailableError()


# Path: zaqarclient/queues/client.py
# _CLIENTS = {1: cv1.Client,
#             1.1: cv1.Client,
#             2: cv2.Client}
# def Client(url=None, version=None, conf=None, session=None):
# 
# Path: zaqarclient/queues/v1/core.py
# def _common_queue_ops(operation, transport, request, name, callback=None):
# def queue_create(transport, request, name,
#                  metadata=None, callback=None):
# def queue_update(transport, request, name, metadata, callback=None):
# def queue_exists(transport, request, name, callback=None):
# def queue_get(transport, request, name, callback=None):
# def queue_get_metadata(transport, request, name, callback=None):
# def queue_set_metadata(transport, request, name, metadata, callback=None):
# def queue_get_stats(transport, request, name):
# def queue_delete(transport, request, name, callback=None):
# def queue_list(transport, request, callback=None, **kwargs):
# def message_list(transport, request, queue_name, callback=None, **kwargs):
# def message_post(transport, request, queue_name, messages, callback=None):
# def message_get(transport, request, queue_name, message_id, callback=None):
# def message_get_many(transport, request, queue_name, messages, callback=None):
# def message_delete(transport, request, queue_name, message_id,
#                    claim_id=None, callback=None):
# def message_delete_many(transport, request, queue_name,
#                         ids, callback=None):
# def message_pop(transport, request, queue_name,
#                 count, callback=None):
# def claim_create(transport, request, queue_name, **kwargs):
# def claim_get(transport, request, queue_name, claim_id):
# def claim_update(transport, request, queue_name, claim_id, **kwargs):
# def claim_delete(transport, request, queue_name, claim_id):
# def pool_get(transport, request, pool_name, callback=None):
# def pool_create(transport, request, pool_name, pool_data):
# def pool_update(transport, request, pool_name, pool_data):
# def pool_list(transport, request, **kwargs):
# def pool_delete(transport, request, pool_name):
# def flavor_create(transport, request, name, flavor_data):
# def flavor_get(transport, request, flavor_name, callback=None):
# def flavor_update(transport, request, flavor_name, flavor_data):
# def flavor_list(transport, request, **kwargs):
# def flavor_delete(transport, request, name):
# def health(transport, request, callback=None):
# 
# Path: zaqarclient/tests/base.py
# _USE_AUTHENTICATION = os.environ.get('ZAQARCLIENT_AUTH_FUNCTIONAL', False)
# _RUN_FUNCTIONAL = os.environ.get('ZAQARCLIENT_TEST_FUNCTIONAL',
#                                  _USE_AUTHENTICATION)
# class TestBase(testtools.TestCase):
#     def setUp(self):
#     def _credentials(self, cloud='devstack-admin'):
#     def _setup_auth_params(self):
#     def config(self, group=None, **kw):
# 
# Path: zaqarclient/transport/errors.py
# class TransportError(errors.ZaqarError):
# class ResourceNotFound(TransportError):
# class MalformedRequest(TransportError):
# class UnauthorizedError(TransportError):
# class ForbiddenError(TransportError):
# class InternalServerError(TransportError):
# class ServiceUnavailableError(TransportError):
# class ConflictError(TransportError):
#     def __init__(self, title=None, description=None, text=None):


# Path: tests/unit/queues/v1/test_client.py
import mock
import ddt
from zaqarclient.queues import client
from zaqarclient.queues.v1 import core
from zaqarclient.tests import base
from zaqarclient.transport import errors



VERSIONS = [1, 1.1]


@ddt.ddt
class TestClient(base.TestBase):

    @ddt.data(*VERSIONS)
    def test_transport(self, version):
        cli = client.Client('http://example.com',
                            version, {"auth_opts": {'backend': 'noauth'}})
        self.assertIsNotNone(cli.transport())

    @ddt.data(*VERSIONS)
    def test_health_ok(self, version):
        cli = client.Client('http://example.com',
                            version, {"auth_opts": {'backend': 'noauth'}})
        with mock.patch.object(core, 'health', autospec=True) as core_health:
            core_health.return_value = None
            self.assertTrue(cli.health())

    @ddt.data(*VERSIONS)
    def test_health_bad(self, version):
        cli = client.Client('http://example.com',
                            version, {"auth_opts": {'backend': 'noauth'}})

        def raise_error(*args, **kwargs):
            raise errors.ServiceUnavailableError()


        with mock.patch.object(core, 'health', autospec=True) as core_health: