title: Django POST Method Unit Test failing with Assertionerror 401
body: <p>I am writing django unittests for an application which is having modules with HTTP get,put and post methods. I have been <a href="http://www.django-rest-framework.org/api-guide/testing#test-cases" rel="nofollow">referencing</a> rest_framework's APITestCase method for writing unittest for POST method.</p>
  
  <p>Here is my code for POST method unittest:</p>
  
  <pre><code>def test_postByTestCase(self):
      url = reverse('lib:ingredient-detail',args=('123',))
      data = {'name':'test_data','status':'draft','config':'null'}
      response = self.client.post(url, data, format='json')
      self.assertEqual(response.status_code, status.HTTP_201_CREATED)
  </code></pre>
  
  <p>By running this test case I am getting this output:</p>
  
  <pre><code>$ python manage.py test lib.IngredientTestCase.test_postByTestCase
  </code></pre>
  
  <p>FDestroying test database for alias 'default'...</p>
  
  <p>======================================================================</p>
  
  <h2>FAIL: test_postByTestCase (lib.tests.IngredientTestCase)</h2>
  
  <p>Traceback (most recent call last):
    File "C:\Apache2\htdocs\iLab\api\lib\tests.py", line 42, in test_postByTestCase
      self.assertEqual(response.status_code, status.HTTP_201_CREATED)
  AssertionError: 401 != 201</p>
  
  <hr>
  
  <p>Ran 1 test in 5.937s</p>
  
  <p>FAILED (failures=1)</p>
  
  <p>I have tried passing HTTP_AUTHORIZATION token value, but it is not helping.</p>