def decorator(func): auth_data = ObjectStorageAuthComposite() objectstorage_api_config = ObjectStorageAPIConfig() client = ObjectStorageAPIClient(auth_data.storage_url, auth_data.auth_token) behaviors = ObjectStorageAPI_Behaviors( client=client, config=objectstorage_api_config) features = behaviors.get_configured_features() if features == objectstorage_api_config.ALL_FEATURES: return func if features == objectstorage_api_config.NO_FEATURES: setattr(func, '__unittest_skip__', True) setattr(func, '__unittest_skip_why__', 'Skipping All Features') features = features.split() missing_reqs = False for req in required_features: if req not in features: missing_reqs = True break if missing_reqs: setattr(func, '__unittest_skip__', True) setattr( func, '__unittest_skip_why__', 'requires features: {0}'.format( ', '.join(required_features))) return func
def __init__(self, exclude=None): api_config = ObjectStorageAPIConfig() auth_data = ObjectStorageAuthComposite() client = ObjectStorageAPIClient( auth_data.storage_url, auth_data.auth_token) behaviors = ObjectStorageAPI_Behaviors(client, api_config) features = behaviors.get_configured_features() if features == api_config.ALL_FEATURES: features = ['dlo', 'slo'] generator = ObjectStorageGenerator(client) if exclude is None: exclude = [] if 'standard' not in exclude: self.append_new_dataset( 'standard', {'object_type': 'standard', 'generate_object': generator.generate_object}) if 'dlo' in features and 'dlo' not in exclude: self.append_new_dataset( 'dlo', {'object_type': 'dlo', 'generate_object': generator.generate_dynamic_large_object}) if 'slo' in features and 'slo' not in exclude: self.append_new_dataset( 'slo', {'object_type': 'slo', 'generate_object': generator.generate_static_large_object})
def required_features(cls, *required_features): """ Test decorator to skip tests if features are not configured in swift. Configuration of what features are enabled can be done from the objectstorage config file. Note: "lambda func: func" is from the Python unit tests example "25.3.6. Skipping tests and expected failures": def skipUnlessHasattr(obj, attr): if hasattr(obj, attr): return lambda func: func return unittest.skip("{!r} doesn't have {!r}".format(obj, attr)) http://docs.python.org/2/library/unittest.html """ auth_data = ObjectStorageAuthComposite() objectstorage_api_config = ObjectStorageAPIConfig() client = ObjectStorageAPIClient(auth_data.storage_url, auth_data.auth_token) behaviors = ObjectStorageAPI_Behaviors( client=client, config=objectstorage_api_config) features = behaviors.get_configured_features() if features == objectstorage_api_config.ALL_FEATURES: return lambda func: func if features == objectstorage_api_config.NO_FEATURES: return unittest.skip('skipping all features') features = features.split() missing_reqs = False for req in required_features: if req not in features: missing_reqs = True break if missing_reqs: return unittest.skip( 'requires features: {0}'.format(', '.join(required_features))) return lambda func: func
def __init__(self, exclude=None): api_config = ObjectStorageAPIConfig() auth_data = ObjectStorageAuthComposite() client = ObjectStorageAPIClient(auth_data.storage_url, auth_data.auth_token) behaviors = ObjectStorageAPI_Behaviors(client, api_config) features = behaviors.get_configured_features() if features == api_config.ALL_FEATURES: features = ['dlo', 'slo'] generator = ObjectStorageGenerator(client) if exclude is None: exclude = [] if 'standard' not in exclude: self.append_new_dataset( 'standard', { 'object_type': 'standard', 'generate_object': generator.generate_object }) if 'dlo' in features and 'dlo' not in exclude: self.append_new_dataset( 'dlo', { 'object_type': 'dlo', 'generate_object': generator.generate_dynamic_large_object }) if 'slo' in features and 'slo' not in exclude: self.append_new_dataset( 'slo', { 'object_type': 'slo', 'generate_object': generator.generate_static_large_object })