Skip to content

Instantly share code, notes, and snippets.

@elcolie
Created October 6, 2017 09:30
Show Gist options
  • Save elcolie/88eb7c90cfca1c369a020ac232c7fbcc to your computer and use it in GitHub Desktop.
Save elcolie/88eb7c90cfca1c369a020ac232c7fbcc to your computer and use it in GitHub Desktop.
Workable patch by using RESTful
def test_mobile_update_customer(self):
user = User.objects.create(username='warhead')
self.client.force_authenticate(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 = self.client.patch(reverse('api:customer-detail', kwargs={'pk': customer.id}), data=data)
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