From 44182fa87f5f499aa7c2876ee0f0c5a84afd12a9 Mon Sep 17 00:00:00 2001 From: Mohammed Junaid Date: Wed, 29 May 2013 06:43:11 +0530 Subject: Unittest case for constraints.py Change-Id: Ibb37855c675d5def2ce2e1ed387429ce87a4926b Signed-off-by: Mohammed Junaid Reviewed-on: http://review.gluster.org/5103 Reviewed-by: Luis Pabon Tested-by: Luis Pabon --- gluster/swift/common/constraints.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'gluster') diff --git a/gluster/swift/common/constraints.py b/gluster/swift/common/constraints.py index d1c990d..1ae8cbb 100644 --- a/gluster/swift/common/constraints.py +++ b/gluster/swift/common/constraints.py @@ -21,12 +21,25 @@ import swift.common.constraints import swift.common.ring as _ring from gluster.swift.common import Glusterfs, ring -if hasattr(swift.common.constraints, 'constraints_conf_int'): - MAX_OBJECT_NAME_COMPONENT_LENGTH = \ - swift.common.constraints.constraints_conf_int( +MAX_OBJECT_NAME_COMPONENT_LENGTH = 255 + +def set_object_name_component_length(len=None): + global MAX_OBJECT_NAME_COMPONENT_LENGTH + + if len: + MAX_OBJECT_NAME_COMPONENT_LENGTH = len + elif hasattr(swift.common.constraints, 'constraints_conf_int'): + MAX_OBJECT_NAME_COMPONENT_LENGTH = \ + swift.common.constraints.constraints_conf_int( 'max_object_name_component_length', 255) -else: - MAX_OBJECT_NAME_COMPONENT_LENGTH = 255 + else: + MAX_OBJECT_NAME_COMPONENT_LENGTH = 255 + return + +set_object_name_component_length() + +def get_object_name_component_length(): + return MAX_OBJECT_NAME_COMPONENT_LENGTH def validate_obj_name_component(obj): -- cgit