Beispiel #1
0
    def test_parse_scheme(self):

        uri = 'http://plop'

        protocol, data_type, data_scope = parse_scheme(uri)

        self.assertEqual(protocol, 'http')
        self.assertEqual(data_type, None)

        uri = '%s%s%s://' % ('http', SCHEME_SEPARATOR, '')

        protocol, data_type, data_scope = parse_scheme(uri)

        self.assertEqual(protocol, 'http')
        self.assertEqual(data_type, '')

        uri = '%s%s%s://' % ('http', SCHEME_SEPARATOR, 'ae')

        protocol, data_type, data_scope = parse_scheme(uri)

        self.assertEqual(protocol, 'http')
        self.assertEqual(data_type, 'ae')
Beispiel #2
0
    def get_middleware_by_uri(self, uri, auto_connect=None, shared=None, sharing_scope=None, *args, **kwargs):

        """
        Load a middleware related to input uri.

        If shared, the result instance is shared among same middleware type
        and self class type.

        :param uri: middleware uri
        :type uri: str

        :param auto_connect: middleware auto_connect parameter
        :type auto_connect: bool

        :param shared: if True, the result is a shared middleware instance
            among managers of the same class. If None, use self.shared.
        :type shared: bool

        :param sharing_scope: scope sharing
        :type sharing_scope: bool

        :return: middleware instance corresponding to the input uri.
        :rtype: Middleware
        """

        protocol, data_type, data_scope = parse_scheme(uri)

        result = self.get_middleware(
            protocol=protocol,
            data_type=data_type,
            data_scope=data_scope,
            auto_connect=auto_connect,
            shared=shared,
            sharing_scope=sharing_scope,
            uri=uri,
            *args,
            **kwargs
        )

        return result