예제 #1
0
    def test_callback_view(self, m_action_info):
        from pyramid_rest.resource import Resource

        context = mock.Mock()
        view = mock.Mock()

        r = Resource('dad')
        r.decorator('index')(view)

        view_info = r._conflicts[view]

        r.callback_view(context, None, view)

        context.config._ainfo.append.assert_called_once_with(
            m_action_info.return_value, )
        context.config.action.assert_called_once_with(('dad', 'index'))
        context.config._ainfo.pop.assert_called_once_with()

        m_action_info.assert_called_once_with(*view_info.info.codeinfo)
예제 #2
0
    def test_callback_view(self, m_action_info):
        from pyramid_rest.resource import Resource

        context = mock.Mock()
        view = mock.Mock()

        r = Resource('dad')
        r.decorator('index')(view)

        view_info = r._conflicts[view]

        r.callback_view(context, None, view)

        context.config._ainfo.append.assert_called_once_with(
            m_action_info.return_value,
            )
        context.config.action.assert_called_once_with(('dad', 'index'))
        context.config._ainfo.pop.assert_called_once_with()

        m_action_info.assert_called_once_with(*view_info.info.codeinfo)
예제 #3
0
    def test_decorator(self, m_venusian, m_ViewInfo):
        from pyramid_rest.resource import Resource

        r = Resource('dad')

        view_index = mock.Mock()

        wrapper = r.decorator('index')
        result = wrapper(view_index)

        self.assertEqual(view_index, result)
        self.assertEqual({'index': m_ViewInfo.return_value}, r.views)

        self.assertEqual(mock.call(r, r.callback),
                         m_venusian.attach.call_args_list[0])
        self.assertEqual(mock.call(view_index, mock.ANY),
                         m_venusian.attach.call_args_list[1])
예제 #4
0
    def test_decorator(self, m_venusian, m_ViewInfo):
        from pyramid_rest.resource import Resource

        r = Resource('dad')

        view_index = mock.Mock()

        wrapper = r.decorator('index')
        result = wrapper(view_index)

        self.assertEqual(view_index, result)
        self.assertEqual(
            {'index': m_ViewInfo.return_value},
            r.views
            )

        self.assertEqual(
            mock.call(r, r.callback),
            m_venusian.attach.call_args_list[0]
            )
        self.assertEqual(
            mock.call(view_index, mock.ANY),
            m_venusian.attach.call_args_list[1]
            )