Ejemplo n.º 1
0
    def test_includeme(self, m_utility):
        from pyramid_rest import (
            includeme,
            RequestMethodEventPredicate,
            override_request_method,
            NewRequest,
        )

        config = mock.Mock()
        config.registry.settings.get.return_value = 'true'

        includeme(config)

        config.registry.registerUtility.assert_called_once_with(
            m_utility.return_value)

        self.assertEqual(
            mock.call(
                'pyramid_rest.tunneling',
                'true',
            ),
            config.registry.settings.get.call_args_list[0],
        )

        config.add_subscriber_predicate.assert_called_once_with(
            'request_methods', RequestMethodEventPredicate)

        config.add_subscriber.assert_called_once_with(
            override_request_method,
            NewRequest,
            request_methods=['POST'],
        )
Ejemplo n.º 2
0
    def test_includeme(self, m_utility):
        from pyramid_rest import (
            includeme,
            RequestMethodEventPredicate,
            override_request_method,
            NewRequest,
            )

        config = mock.Mock()
        config.registry.settings.get.return_value = 'true'

        includeme(config)

        config.registry.registerUtility.assert_called_once_with(
            m_utility.return_value
            )

        self.assertEqual(
            mock.call('pyramid_rest.tunneling', 'true', ),
            config.registry.settings.get.call_args_list[0],
            )

        config.add_subscriber_predicate.assert_called_once_with(
            'request_methods',
            RequestMethodEventPredicate
            )

        config.add_subscriber.assert_called_once_with(
            override_request_method,
            NewRequest,
            request_methods=['POST'],
            )
Ejemplo n.º 3
0
    def test_includeme_no_tunnelling(self):
        from pyramid_rest import includeme

        config = mock.Mock()
        config.registry.settings.get.return_value = 'false'

        includeme(config)

        self.assertFalse(config.add_subscriber_predicate.called)
        self.assertFalse(config.add_subscriber.called)
Ejemplo n.º 4
0
    def test_includeme_no_tunnelling(self):
        from pyramid_rest import includeme

        config = mock.Mock()
        config.registry.settings.get.return_value = 'false'

        includeme(config)

        self.assertFalse(config.add_subscriber_predicate.called)
        self.assertFalse(config.add_subscriber.called)