Exemplo n.º 1
0
    def test_attrs_are_applied_as_defaults(self, parameter, value,
                                           mock_container):
        """ Verify that you can specify some fields by subclassing the
        EventDispatcher DependencyProvider.
        """
        dispatcher_cls = type("LegacyEventDispatcher", (EventDispatcher, ),
                              {parameter: value})
        with patch('nameko.messaging.warnings') as warnings:
            mock_container.config = {'AMQP_URI': 'memory://'}
            mock_container.service_name = "service"
            dispatcher = dispatcher_cls().bind(mock_container, "dispatch")
        assert warnings.warn.called
        call_args = warnings.warn.call_args
        assert parameter in unpack_mock_call(call_args).positional[0]

        dispatcher.setup()
        assert getattr(dispatcher.publisher, parameter) == value
Exemplo n.º 2
0
    def test_attrs_are_applied_as_defaults(
        self, parameter, value, mock_container
    ):
        """ Verify that you can specify some fields by subclassing the
        EventDispatcher DependencyProvider.
        """
        publisher_cls = type(
            "LegacPublisher", (Publisher,), {parameter: value}
        )
        with patch('nameko.messaging.warnings') as warnings:
            mock_container.config = {'AMQP_URI': 'memory://'}
            mock_container.service_name = "service"
            publisher = publisher_cls().bind(mock_container, "publish")
        assert warnings.warn.called
        call_args = warnings.warn.call_args
        assert parameter in unpack_mock_call(call_args).positional[0]

        publisher.setup()
        assert getattr(publisher.publisher, parameter) == value
Exemplo n.º 3
0
    def test_attrs_are_applied_as_defaults(self, parameter, value,
                                           mock_container):
        """ Verify that you can specify some fields by subclassing the
        MethodProxy class.
        """
        method_proxy_cls = type("LegacyMethodProxy", (MethodProxy, ),
                                {parameter: value})
        with patch('nameko.rpc.warnings') as warnings:
            worker_ctx = Mock()
            worker_ctx.container.config = {'AMQP_URI': 'memory://'}
            reply_listener = Mock()
            proxy = method_proxy_cls(worker_ctx, "service", "method",
                                     reply_listener)

        assert warnings.warn.called
        call_args = warnings.warn.call_args
        assert parameter in unpack_mock_call(call_args).positional[0]

        assert getattr(proxy.publisher, parameter) == value