Example #1
0
    def test_should_use_view__get_queryset__and_filter_it_with__filter_queryset__and_filter_by__lookup_field(self):
        model = BitTestModel.objects.create(is_active=True)
        self.kwargs['view_instance'].kwargs = {'id': model.id}

        expected = u"[(%s, True)]" % model.id

        response = RetrieveModelKeyBit().get_data(**self.kwargs)
        self.assertEqual(response, expected)
Example #2
0
 def test_should_return_none_if_empty_result_set_raised(self):
     self.kwargs['view_instance'].filter_queryset = lambda x: x.filter(pk__in=[])
     response = RetrieveModelKeyBit().get_data(**self.kwargs)
     self.assertEqual(response, None)
Example #3
0
 def test_with_bad_lookup_value(self):
     self.kwargs['view_instance'].kwargs = {'id': "I'm ganna hack u are!"}
     response = RetrieveModelKeyBit().get_data(**self.kwargs)
     self.assertEqual(response, None)