示例#1
0
    def test_client_settings_fails_with_server_middleware(self):
        """The client settings fail to validate with server middleware"""

        settings_dict = {
            'transport': {
                'path':
                'pysoa.common.transport.redis_gateway.client:RedisClientTransport',
                'kwargs': {
                    'backend_type': REDIS_BACKEND_TYPE_STANDARD,
                }
            },
            'middleware': [{
                'path': 'pysoa.server.middleware:ServerMiddleware'
            }],
        }

        with self.assertRaises(Settings.ImproperlyConfigured) as error_context:
            ClientSettings(settings_dict)

        self.assertTrue('should be of type' in error_context.exception.args[0])

        settings_dict['middleware'][0][
            'path'] = 'pysoa.client.middleware:ClientMiddleware'

        ClientSettings(settings_dict)
    def test_client_settings_fails_with_server_middleware(self):
        """The client settings fail to validate with server middleware"""

        settings_dict = {
            'transport': {
                'path': 'pysoa.common.transport.redis_gateway.client:RedisClientTransport',
                'kwargs': {
                    'backend_type': REDIS_BACKEND_TYPE_STANDARD,
                }
            },
            'middleware': [
                {'path': 'pysoa.server.middleware:ServerMiddleware'}
            ],
        }

        with pytest.raises(Settings.ImproperlyConfigured) as error_context:
            ClientSettings(settings_dict)

        assert 'is not one of or a subclass of one of' in error_context.value.args[0]
        assert 'ServerMiddleware' in error_context.value.args[0]

        settings_dict['middleware'][0]['path'] = 'pysoa.client.middleware:ClientMiddleware'  # type: ignore

        ClientSettings(settings_dict)
示例#3
0
    def test_client_settings_fails_with_server_transport(self):
        """The client settings fail to validate with server transport"""

        settings_dict = {
            'transport': {
                'path':
                'pysoa.common.transport.redis_gateway.server:RedisServerTransport',
                'kwargs': {
                    'backend_type': REDIS_BACKEND_TYPE_STANDARD,
                }
            },
        }

        with self.assertRaises(Settings.ImproperlyConfigured) as error_context:
            ClientSettings(settings_dict)

        self.assertTrue('should be of type' in error_context.exception.args[0])
    def test_client_settings_fails_with_invalid_path(self):
        """The client settings fail to validate with non-existent transport"""

        settings_dict = {
            'transport': {
                'path': 'pysoa.common.transport.redis_gateway.server:NonExistentTransport',
                'kwargs': {
                    'backend_type': REDIS_BACKEND_TYPE_STANDARD,
                }
            },
        }

        with pytest.raises(Settings.ImproperlyConfigured) as error_context:
            ClientSettings(settings_dict)

        assert 'has no attribute' in error_context.value.args[0]
        assert 'NonExistentTransport' in error_context.value.args[0]
    def test_client_settings_fails_with_server_transport(self):
        """The client settings fail to validate with server transport"""

        settings_dict = {
            'transport': {
                'path': 'pysoa.common.transport.redis_gateway.server:RedisServerTransport',
                'kwargs': {
                    'backend_type': REDIS_BACKEND_TYPE_STANDARD,
                }
            },
        }

        with pytest.raises(Settings.ImproperlyConfigured) as error_context:
            ClientSettings(settings_dict)

        assert 'is not one of or a subclass of one of' in error_context.value.args[0]
        assert 'RedisServerTransport' in error_context.value.args[0]
示例#6
0
    def test_client_settings_fails_with_invalid_path(self):
        """The client settings fail to validate with non-existent transport"""

        settings_dict = {
            'transport': {
                'path':
                'pysoa.common.transport.redis_gateway.server:NonExistentTransport',
                'kwargs': {
                    'backend_type': REDIS_BACKEND_TYPE_STANDARD,
                }
            },
        }

        with self.assertRaises(Settings.ImproperlyConfigured) as error_context:
            ClientSettings(settings_dict)

        self.assertTrue(
            'Could not resolve path' in error_context.exception.args[0])