def test_get_response(self):
        request = request_factory.get("/", {'q': 'c'})
        autocomplete = ObjectAutocomplete(
            model=User, search_fields=['username'],
            response_fields=['username']
        )
        autocomplete.request = request
        results = autocomplete.get_result_queryset()
        response = autocomplete.get_response(results)

        qs = User.objects.filter(username__startswith='c').values('username')
        compare = simplejson.dumps(list(qs))
        self.assertEquals('text/javascript', response['Content-Type'])
        self.assertEquals(compare, response.content)
 def test_get_response_fields(self):
     autocomplete = ObjectAutocomplete(model=User)
     self.assertEquals(None, autocomplete.get_response_fields())
     autocomplete = ObjectAutocomplete(model=User, response_fields=['username'])
     self.assertEquals(['username'], autocomplete.get_response_fields())
     class TestAutocomplete(ObjectAutocomplete):
         model = User
         response_fields = ['id']
     autocomplete = TestAutocomplete()
     self.assertEquals(['id'], autocomplete.get_response_fields())