Dear all,

Using APIClient (not the requests based class) is it possible to pass as 
param the accept_language?


class BaseAPITestCase(APITestCase):
    @classmethod
    def setUpTestData(cls):
        def _get_jwt_token(user_credentials):
            url_token_auth = reverse('api:default:api-token-auth')
            response = cls.client.post(url_token_auth, user_credentials, 
format='json')
            assert response.status_code == status.HTTP_200_OK
            return response.data['token']

        cls.client = APIClient(enforce_csrf_checks=True)

        cls.user1 = {}
        cls.user1['user'] = get_user_model().objects.get(username='user1')
        cls.user1['auth'] = 'JWT {0}'.format(_get_jwt_token({'username': cls
.user1['user'].username,
                                                             'password': 
'password'}))

class TestBase(BaseAPITestCase):
    def test_flags(self):
        url = reverse('api:default:flags-list')
        response = self.client.get(url, HTTP_AUTHORIZATION=self.user1['auth'
])
        self.assertEqual(response.status_code, status.HTTP_200_OK)



Using the JSON Token it works great 
response = self.client.get(url, HTTP_AUTHORIZATION='JWT <value>')
but this doesn't
response = self.client.get(url, ACCEPT_LANGUAGE='es', HTTP_AUTHORIZATION='JWT 
<value>')


I would need to mimic: 

curl -H "Accept-Language: it" http://localhost:8001/v1/flags/
curl -H "Accept-Language: en" http://localhost:8001/v1/flags/
curl -H "Accept-Language: es" http://localhost:8001/v1/flags/

Thanks.

D

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to