> + def test_post_ticket(self):
> + # Check how many are there first.
> + self.assertEqual(Ticket.objects.count(), 1)
> + self.post(resource=self.resource, params=self.post_ticket_data)
> + # Verify a new one has been added.
> + self.assertEqual(Ticket.objects.count(), 2)
might be worth taking the ID from self.post and making sure the
post_ticket_data matches the object that got created. not a big deal though.
> + def test_patch_detail(self):
> + # Grab the current data & modify it slightly.
> + original_data = self.getResource(self.detail_url)
> + new_data = original_data.copy()
> + new_data['owner'] = '<email address hidden>'
> +
> + self.assertEqual(Ticket.objects.count(), 1)
> + resp = self.client.patch('/api/v1/' + self.detail_url, data=new_data)
> + self.assertHttpMethodNotAllowed(resp)
> + # Make sure the count hasn't changed & we did an update.
> + self.assertEqual(Ticket.objects.count(), 1)
> + # Check for updated data.
> + self.assertEqual(Ticket.objects.get(pk=self.ticket.pk).owner,
> + self.ticket.owner)
Should this assert be:
self.assertEqual(Ticket.objects.get(pk=self.ticket.pk).owner, new_data['owner'])
On 12/19/2013 02:28 PM, Chris Johnston wrote:
> === added file 'ticket_ system/ ticket/ tests/test_ write_api. py'
> + def test_post_ ticket( self): l(Ticket. objects. count() , 1) resource= self.resource, params= self.post_ ticket_ data) l(Ticket. objects. count() , 2)
> + # Check how many are there first.
> + self.assertEqua
> + self.post(
> + # Verify a new one has been added.
> + self.assertEqua
might be worth taking the ID from self.post and making sure the
post_ticket_data matches the object that got created. not a big deal though.
> + def test_patch_ detail( self): e(self. detail_ url) data.copy( ) l(Ticket. objects. count() , 1) patch(' /api/v1/ ' + self.detail_url, data=new_data) MethodNotAllowe d(resp) l(Ticket. objects. count() , 1) l(Ticket. objects. get(pk= self.ticket. pk).owner,
> + # Grab the current data & modify it slightly.
> + original_data = self.getResourc
> + new_data = original_
> + new_data['owner'] = '<email address hidden>'
> +
> + self.assertEqua
> + resp = self.client.
> + self.assertHttp
> + # Make sure the count hasn't changed & we did an update.
> + self.assertEqua
> + # Check for updated data.
> + self.assertEqua
> + self.ticket.owner)
Should this assert be: assertEqual( Ticket. objects. get(pk= self.ticket. pk).owner,
new_ data['owner' ])
self.