Skip to content

Instantly share code, notes, and snippets.

@elcolie
Created October 6, 2017 10:01
Show Gist options
  • Save elcolie/54a15b300c0b4c0aeed80c6edc67261f to your computer and use it in GitHub Desktop.
Save elcolie/54a15b300c0b4c0aeed80c6edc67261f to your computer and use it in GitHub Desktop.
def test_mobile_update_customer(self):
user = User.objects.create(username='warhead')
from django.test import Client
client = Client()
client.force_login(user=user)
mommy.make(Customer, family_name='IBM', created_user=self.soken_staff, updated_user=self.soken_staff)
data = {
"family_name": "C0D1UM"
}
customer = Customer.objects.first()
res = client.patch(reverse('api:customer-detail', kwargs={'pk': customer.id}), data=data, content_type='application/json')
self.assertEqual(200, res.status_code)
customer.refresh_from_db()
self.assertEqual('C0D1UM', customer.family_name)
self.assertEqual('spearhead', customer.created_user.username)
self.assertEqual('warhead', customer.updated_user.username)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment