Пример #1
0
    def _test_wildcard_iterator(cls, uri_or_str, debug=0):
        """Convenience method for instantiating a test instance of WildcardIterator.

    This makes it unnecessary to specify all the params of that class
    (like bucket_storage_uri_class=mock_storage_service.MockBucketStorageUri).
    Also, naming the factory method this way makes it clearer in the test code
    that WildcardIterator needs to be set up for testing.

    Args are same as for wildcard_iterator.wildcard_iterator(), except
    there are no class args for bucket_storage_uri_class or gsutil_api_class.

    Args:
      uri_or_str: StorageUri or string representing the wildcard string.
      debug: debug level to pass to the underlying connection (0..3)

    Returns:
      WildcardIterator, over which caller can iterate.
    """
        # TODO: Remove when tests no longer pass StorageUri arguments.
        uri_string = uri_or_str
        if hasattr(uri_or_str, 'uri'):
            uri_string = uri_or_str.uri

        return wildcard_iterator.CreateWildcardIterator(
            uri_string, cls.MakeGsUtilApi())
Пример #2
0
    def _test_wildcard_iterator(cls, uri_or_str, debug=0):
        """Convenience method for instantiating a test instance of WildcardIterator.

    This makes it unnecessary to specify all the params of that class
    (like bucket_storage_uri_class=mock_storage_service.MockBucketStorageUri).
    Also, naming the factory method this way makes it clearer in the test code
    that WildcardIterator needs to be set up for testing.

    Args are same as for wildcard_iterator.wildcard_iterator(), except
    there are no class args for bucket_storage_uri_class or gsutil_api_class.

    Args:
      uri_or_str: StorageUri or string representing the wildcard string.
      debug: debug level to pass to the underlying connection (0..3)

    Returns:
      WildcardIterator, over which caller can iterate.
    """
        # TODO: Remove when tests no longer pass StorageUri arguments.
        uri_string = uri_or_str
        if hasattr(uri_or_str, 'uri'):
            uri_string = uri_or_str.uri

        cls.gsutil_api_map = {
            ApiMapConstants.API_MAP:
            (cls.mock_gsutil_api_class_map_factory.GetClassMap()),
            ApiMapConstants.SUPPORT_MAP: {
                'gs': [ApiSelector.XML, ApiSelector.JSON],
                's3': [ApiSelector.XML]
            },
            ApiMapConstants.DEFAULT_MAP: {
                'gs': ApiSelector.JSON,
                's3': ApiSelector.XML
            }
        }

        cls.gsutil_api = CloudApiDelegator(cls.mock_bucket_storage_uri,
                                           cls.gsutil_api_map,
                                           cls.logger,
                                           debug=debug)

        return wildcard_iterator.CreateWildcardIterator(
            uri_string, cls.gsutil_api)