# Path: oioswift/common/middleware/container_hierarchy.py
#     class RedisConnection(object):
# class RedisDb(RedisConnection):
# class FakeRedis(object):
# class ContainerHierarchyMiddleware(AutoContainerBase):
#         URL_QUERY_ARGUMENT_PARSERS = {
#             'socket_timeout': float,
#             'socket_connect_timeout': float,
#             'socket_keepalive': config_true_value,
#             'retry_on_timeout': config_true_value,
#             'max_connections': int,
#             'health_check_interval': int,
#         }
# LOG = None
# MIDDLEWARE_NAME = 'container_hierarchy'
# DEFAULT_LIMIT = 10000
# REDIS_KEYS_FORMAT_V1 = 'v1'
# REDIS_KEYS_FORMAT_V2 = 'v2'
# REDIS_KEYS_FORMAT_V3 = 'v3'
# OBJ = 'obj'
# CNT = 'cnt'
# FAKE_ACL = '''{"Owner":"internal:internal",
#                "Grant":[{"Grantee":"AllUsers","Permission":"READ"},
#                         {"Grantee":"AllUsers","Permission":"WRITE"}]}'''
#     DELIMITER = '/'
#     ENCODED_DELIMITER = '%2F'
#     SWIFT_SOURCE = 'SHARD'
#     PREFIX = 'CS:'
#     LOG = get_logger(conf)
#         def __init__(self, host=None, sentinel_hosts=None,
#                      sentinel_name=None, **kwargs):
#         def _filter_conn_kwargs(self, conn_kwargs):
#         def _filter_sentinel_conn_kwargs(self, sentinel_conn_kwargs):
#         def conn(self):
#         def conn_slave(self):
#         def register_script(self, script):
#     def __init__(self, host=None, sentinel_hosts=None, sentinel_name=None,
#                  **kwargs):
#     def set(self, key, val):
#     def setnx(self, key, val):
#     def hset(self, key, path, val):
#     def hsetnx(self, key, path, val):
#     def zset3(self, key, path):
#     def zset_legacy(self, key, path):
#     def delete(self, key):
#     def hdel(self, key, hkey):
#     def zdel(self, key, zkey):
#     def keys(self, pattern, count=DEFAULT_LIMIT):
#     def hkeys(self, key, match=None, count=DEFAULT_LIMIT):
#     def zkeys(self, key, prefix, delimiter, marker=None, recursive=False,
#               limit=DEFAULT_LIMIT, exclude_marker=False):
#     def exists(self, key):
#     def hexists(self, key, hkey):
#     def zexists(self, key, zkey):
#     def __init__(self):
#     def set(self, key, val):
#     def setnx(self, key, val):
#     def hset(self, key, path, val):
#     def hsetnx(self, key, path, val):
#     def delete(self, key):
#     def hdel(self, key, hkey):
#     def zdel(self, key, zkey):
#     def hkeys(self, key, match=None):
#     def zkeys(self, key, prefix, delimiter, marker=None, recursive=False,
#               limit=DEFAULT_LIMIT):
#     def keys(self, pattern):
#     def exists(self, key):
#     def hexists(self, key, hkey):
#     def zexists(self, key, zkey):
#     def __init__(self, app, conf, acct, mask_empty_prefixes=None,
#                  redis_conf=None, **kwargs):
#     def check_pipeline(self, conf):
#     def key(self, account, container, mode, path=None):
#     def _create_placeholder(self, req, account, container, mode, path):
#     def _remove_placeholder(self, req, account, container, mode, path):
#     def _build_object_listing_mpu(self, start_response, env,
#                                   account, container, prefix,
#                                   limit=DEFAULT_LIMIT,
#                                   recursive=False, marker=None):
#         def header_cb(header_dict):
#     def has_nested_subdir(self, key, subdir):
#     def hosts_visible_objects(self, env, account, container, prefix):
#     def prefix_can_be_listed(self, env, account, container, prefix):
#     def _build_object_listing(self, start_response, env,
#                               account, container, prefix,
#                               limit=DEFAULT_LIMIT,
#                               recursive=False, marker=None, is_mpu=False):
#         def header_cb(header_dict):
#     def _container_suffix(self, obj_parts, is_mpu, sep=None):
#     def _fake_container_and_obj(self, container, obj_parts, is_listing=False,
#                                 is_mpu=False):
#     def _list_objects(self, env, account, ct_parts, header_cb,
#                       prefix='', limit=DEFAULT_LIMIT,
#                       marker=None, force_master=False, versions=False):
#     def should_bypass(self, env):
#     def update_copy_headers(self, req, env2):
#     def _handle_dir_object(self, req, start_response, account, container,
#                            path):
#     def __call__(self, env, start_response):
# def filter_factory(global_conf, **local_config):
#     def factory(app):
# 
# Path: oioswift/common/middleware/container_hierarchy.py
# REDIS_KEYS_FORMAT_V1 = 'v1'
# 
# REDIS_KEYS_FORMAT_V2 = 'v2'


import os.path
import json
import mock
import sys
import unittest
from swift.common import swob, utils
from swift.common.swob import Request, HTTPException
from oioswift.common.middleware import container_hierarchy
from oioswift.common.middleware.container_hierarchy import \
    REDIS_KEYS_FORMAT_V1, REDIS_KEYS_FORMAT_V2
from test.unit.common.middleware.helpers import FakeSwift  # noqa


# Hack PYTHONPATH so "test" is swift's test directory
sys.path.insert(1, os.path.abspath(os.path.join(__file__, '../../../../..')))


class OioContainerHierarchy(unittest.TestCase):
    def setUp(self):
        conf = {'sds_default_account': 'OPENIO'}
        self.filter_conf = {
            'strip_v1': 'true',
            'swift3_compat': 'true',
            'account_first': 'true'
        }
        self.app = FakeSwift()

# Path: oioswift/common/middleware/container_hierarchy.py
#     class RedisConnection(object):
# class RedisDb(RedisConnection):
# class FakeRedis(object):
# class ContainerHierarchyMiddleware(AutoContainerBase):
#         URL_QUERY_ARGUMENT_PARSERS = {
#             'socket_timeout': float,
#             'socket_connect_timeout': float,
#             'socket_keepalive': config_true_value,
#             'retry_on_timeout': config_true_value,
#             'max_connections': int,
#             'health_check_interval': int,
#         }
# LOG = None
# MIDDLEWARE_NAME = 'container_hierarchy'
# DEFAULT_LIMIT = 10000
# REDIS_KEYS_FORMAT_V1 = 'v1'
# REDIS_KEYS_FORMAT_V2 = 'v2'
# REDIS_KEYS_FORMAT_V3 = 'v3'
# OBJ = 'obj'
# CNT = 'cnt'
# FAKE_ACL = '''{"Owner":"internal:internal",
#                "Grant":[{"Grantee":"AllUsers","Permission":"READ"},
#                         {"Grantee":"AllUsers","Permission":"WRITE"}]}'''
#     DELIMITER = '/'
#     ENCODED_DELIMITER = '%2F'
#     SWIFT_SOURCE = 'SHARD'
#     PREFIX = 'CS:'
#     LOG = get_logger(conf)
#         def __init__(self, host=None, sentinel_hosts=None,
#                      sentinel_name=None, **kwargs):
#         def _filter_conn_kwargs(self, conn_kwargs):
#         def _filter_sentinel_conn_kwargs(self, sentinel_conn_kwargs):
#         def conn(self):
#         def conn_slave(self):
#         def register_script(self, script):
#     def __init__(self, host=None, sentinel_hosts=None, sentinel_name=None,
#                  **kwargs):
#     def set(self, key, val):
#     def setnx(self, key, val):
#     def hset(self, key, path, val):
#     def hsetnx(self, key, path, val):
#     def zset3(self, key, path):
#     def zset_legacy(self, key, path):
#     def delete(self, key):
#     def hdel(self, key, hkey):
#     def zdel(self, key, zkey):
#     def keys(self, pattern, count=DEFAULT_LIMIT):
#     def hkeys(self, key, match=None, count=DEFAULT_LIMIT):
#     def zkeys(self, key, prefix, delimiter, marker=None, recursive=False,
#               limit=DEFAULT_LIMIT, exclude_marker=False):
#     def exists(self, key):
#     def hexists(self, key, hkey):
#     def zexists(self, key, zkey):
#     def __init__(self):
#     def set(self, key, val):
#     def setnx(self, key, val):
#     def hset(self, key, path, val):
#     def hsetnx(self, key, path, val):
#     def delete(self, key):
#     def hdel(self, key, hkey):
#     def zdel(self, key, zkey):
#     def hkeys(self, key, match=None):
#     def zkeys(self, key, prefix, delimiter, marker=None, recursive=False,
#               limit=DEFAULT_LIMIT):
#     def keys(self, pattern):
#     def exists(self, key):
#     def hexists(self, key, hkey):
#     def zexists(self, key, zkey):
#     def __init__(self, app, conf, acct, mask_empty_prefixes=None,
#                  redis_conf=None, **kwargs):
#     def check_pipeline(self, conf):
#     def key(self, account, container, mode, path=None):
#     def _create_placeholder(self, req, account, container, mode, path):
#     def _remove_placeholder(self, req, account, container, mode, path):
#     def _build_object_listing_mpu(self, start_response, env,
#                                   account, container, prefix,
#                                   limit=DEFAULT_LIMIT,
#                                   recursive=False, marker=None):
#         def header_cb(header_dict):
#     def has_nested_subdir(self, key, subdir):
#     def hosts_visible_objects(self, env, account, container, prefix):
#     def prefix_can_be_listed(self, env, account, container, prefix):
#     def _build_object_listing(self, start_response, env,
#                               account, container, prefix,
#                               limit=DEFAULT_LIMIT,
#                               recursive=False, marker=None, is_mpu=False):
#         def header_cb(header_dict):
#     def _container_suffix(self, obj_parts, is_mpu, sep=None):
#     def _fake_container_and_obj(self, container, obj_parts, is_listing=False,
#                                 is_mpu=False):
#     def _list_objects(self, env, account, ct_parts, header_cb,
#                       prefix='', limit=DEFAULT_LIMIT,
#                       marker=None, force_master=False, versions=False):
#     def should_bypass(self, env):
#     def update_copy_headers(self, req, env2):
#     def _handle_dir_object(self, req, start_response, account, container,
#                            path):
#     def __call__(self, env, start_response):
# def filter_factory(global_conf, **local_config):
#     def factory(app):
# 
# Path: oioswift/common/middleware/container_hierarchy.py
# REDIS_KEYS_FORMAT_V1 = 'v1'
# 
# REDIS_KEYS_FORMAT_V2 = 'v2'


# Path: tests/unit/common/middleware/test_container_hierarchy.py
import os.path
import json
import mock
import sys
import unittest
from swift.common import swob, utils
from swift.common.swob import Request, HTTPException
from oioswift.common.middleware import container_hierarchy
from oioswift.common.middleware.container_hierarchy import \
    REDIS_KEYS_FORMAT_V1, REDIS_KEYS_FORMAT_V2
from test.unit.common.middleware.helpers import FakeSwift  # noqa



# Hack PYTHONPATH so "test" is swift's test directory
sys.path.insert(1, os.path.abspath(os.path.join(__file__, '../../../../..')))


class OioContainerHierarchy(unittest.TestCase):
    def setUp(self):
        conf = {'sds_default_account': 'OPENIO'}
        self.filter_conf = {
            'strip_v1': 'true',
            'swift3_compat': 'true',
            'account_first': 'true'
        }
        self.app = FakeSwift()

        self.ch = container_hierarchy.filter_factory(