コード例 #1
0
ファイル: test_settings.py プロジェクト: zetahernandez/pysoa
    def test_server_settings_fails_with_client_middleware(self):
        """The server settings fail to validate with client middleware"""

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

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

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

        settings_dict['middleware'][0][
            'path'] = 'pysoa.server.middleware:ServerMiddleware'

        ServerSettings(settings_dict)
コード例 #2
0
ファイル: test_settings.py プロジェクト: zetahernandez/pysoa
    def test_server_settings(self):
        """The server is successfully instantiated with settings, Redis Transport"""
        class _TestServer(Server):
            service_name = 'geo_tag'

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

        server = _TestServer(ServerSettings(settings_dict))

        assert isinstance(server.transport, RedisServerTransport)
        assert server.transport._receive_queue_name == 'service.geo_tag'
        assert isinstance(server.transport.core, RedisTransportCore)
        assert server.transport.core.backend_type == REDIS_BACKEND_TYPE_STANDARD
        assert isinstance(server.transport.core.default_serializer,
                          JSONSerializer)
コード例 #3
0
    def test_server_settings_fails_with_client_transport(self):
        """The server settings fail to validate with client transport"""

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

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

        assert 'is not one of or a subclass of one of' in error_context.value.args[0]
コード例 #4
0
    def test_server_settings_fails_with_client_transport(self):
        """The server settings fail to validate with client transport"""

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

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

        self.assertTrue('should be of type' in error_context.exception.args[0])
コード例 #5
0
    def test_server_settings_fails_with_invalid_serializer(self):
        """The server settings fail to validate with server middleware as serializer"""

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

        with pytest.raises(Settings.ImproperlyConfigured) as error_context:
            ServerSettings(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]