def test_should_use_view__get_queryset__and_filter_it_with__filter_queryset(self): # create 4 models BitTestModel.objects.create(is_active=True) BitTestModel.objects.create(is_active=True) BitTestModel.objects.create(is_active=True) BitTestModel.objects.create(is_active=True) expected = u"[(1, True), (2, True), (3, True), (4, True)]" response = ListModelKeyBit().get_data(**self.kwargs) self.assertEqual(response, expected)
def test_should_return_none_if_empty_result_set_raised(self): self.kwargs['view_instance'].filter_queryset = lambda x: x.filter(pk__in=[]) response = ListModelKeyBit().get_data(**self.kwargs) self.assertEqual(response, None)