Skip to content

Instantly share code, notes, and snippets.

@ianawilson
Last active December 21, 2015 02:09
Show Gist options
  • Save ianawilson/6232946 to your computer and use it in GitHub Desktop.
Save ianawilson/6232946 to your computer and use it in GitHub Desktop.
Demonstrating a problem with patching and the Tastypie api client.
from django.contrib.auth.models import User
from tastypie.test import ResourceTestCase
class Test(ResourceTestCase):
def test_patch(self):
user = User(username='username', email='test@test.com')
user.set_password('password')
user.save()
uri = '/api/v1/users/%s' % user.pk
data = {
'email': 'new@test.com',
}
response = self.api_client.patch(uri, authentication=self.create_basic('username', 'password'), data=data)
self.assertHttpAccepted(response)
user = User.objects.get(pk=user.pk)
self.assertEqual(user.email, 'new@test.com')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment