Code review comment for lp:~cjohnston/ubuntu-ci-services-itself/write-ticket-resource

Revision history for this message
Andy Doan (doanac) wrote :

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):
> + # 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'])

« Back to merge proposal