old_contents: import json
  from api.tests.test_api import IntegrationTestAPICase
  
  
  class IntegrationTestUserAPI(IntegrationTestAPICase):
  
      def test_user_list(self):
          self._login_user_and_profile()
          response = self.client.get('/api/v1/users')
          data = [{'username': u'bob', 'first_name': u'Bob', 'last_name': u''}]
          self.assertContains(response, json.dumps(data))
  
      def test_user_get(self):
          self._login_user_and_profile()
          response = self.client.get('/api/v1/users/bob')
          data = {'username': u'bob', 'first_name': u'Bob', 'last_name': u''}
          self.assertContains(response, json.dumps(data))
  
new_contents: import json
  from api.tests.test_api import TestAPICase
  from api.views import UserViewSet
  
  
  class TestUsersAPI(TestAPICase):
      def setUp(self):
          super(TestUsersAPI, self).setUp()
  
      def test_user_list(self):
          view = UserViewSet.as_view({'get': 'list'})
          request = self.factory.get('/', **self.extra)
          response = view(request)
          data = [{'username': u'bob', 'first_name': u'Bob', 'last_name': u''}]
          self.assertContains(response, json.dumps(data))
  
      def test_user_get(self):
          view = UserViewSet.as_view({'get': 'retrieve'})
          request = self.factory.get('/', **self.extra)
          response = view(request, username='bob')
          data = {'username': u'bob', 'first_name': u'Bob', 'last_name': u''}
          self.assertContains(response, json.dumps(data))
  
subject: refactor to use RequestFactory