예제 #1
0
 def test_get_queryset(self):
     """Establish that our `get_queryset` method filters in the
     way we expect.
     """
     mvs = ModelViewSet()
     with mock.patch.object(ModelViewSet.mro()[1], 'get_queryset') as m:
         qs = mvs.get_queryset()
         self.assertEqual(qs, m.return_value)
예제 #2
0
 def test_get_queryset(self):
     """Establish that our `get_queryset` method filters in the
     way we expect.
     """
     mvs = ModelViewSet()
     with mock.patch.object(ModelViewSet.mro()[1], 'get_queryset') as m:
         qs = mvs.get_queryset()
         self.assertEqual(qs, m.return_value)
예제 #3
0
 def test_get_queryset_with_kwargs(self):
     """Establish that our `get_queryset` method filters in the way
     we expect if we have unknown keyword arguments (which typically come
     from parent viewsets).
     """
     mvs = ModelViewSet(kwargs={'foo__pk': 42})
     with mock.patch.object(ModelViewSet.mro()[1], 'get_queryset') as m:
         m.return_value = mock.MagicMock()
         qs = mvs.get_queryset()
         self.assertEqual(m.return_value.mock_calls,
                          [mock.call.filter(foo__pk=42)])
예제 #4
0
 def test_get_queryset_with_kwargs(self):
     """Establish that our `get_queryset` method filters in the way
     we expect if we have unknown keyword arguments (which typically come
     from parent viewsets).
     """
     mvs = ModelViewSet(kwargs={'foo__pk': 42})
     with mock.patch.object(ModelViewSet.mro()[1], 'get_queryset') as m:
         m.return_value = mock.MagicMock()
         qs = mvs.get_queryset()
         self.assertEqual(m.return_value.mock_calls,
                          [mock.call.filter(foo__pk=42)])