def test_key_in_post(self):
        self.client.login(username='miles', password='pw')
        data = {
            'data': {
                'type': 'users',
                'id': encoding.force_text(self.miles.pk),
                'attributes': {
                    'first-name': self.miles.first_name,
                    'last-name': self.miles.last_name,
                    'email': 'miles@trumpet.org'
                },
            }
        }

        response = self.client.put(self.detail_url,
                                   content_type='application/vnd.api+json',
                                   data=dump_json(data))

        content_dump = redump_json(response.content)
        expected_dump = dump_json(data)

        assert expected_dump == content_dump

        # is it updated?
        self.assertEqual(
            get_user_model().objects.get(pk=self.miles.pk).email,
            'miles@trumpet.org')
Ensure a key is in the post.
dataset/ETHPy150Open django-json-api/django-rest-framework-json-api/example/tests/test_model_viewsets.py/ModelViewSetTests.test_key_in_post