示例#1
0
 def test_get_context_data(self):
     """
     Test :py:meth:`.JSONView.get_context_data`.
     """
     view = JSONView()
     self.assertEqual({
         'params': {
             'foo': 'bar',
         }
     }, view.get_context_data(foo='bar'))
示例#2
0
    def test_get(self):
        """
        Test :py:meth:`.JSONView.get`.
        """
        view = JSONView()
        view.get_context_data = Mock(return_value={'foo': 'bar'})
        view.render_to_response = Mock(return_value='response')

        self.assertEqual('response', view.get(bar='foo'))
        view.get_context_data.assert_called_once_with(bar='foo')
        view.render_to_response.assert_called_once_with({'foo': 'bar'})