def test_failure(self, action, decision): """ If the action fails, the view should return HTTP 500 and the serialized Refund. """ with mock.patch( 'ecommerce.extensions.refund.models.Refund.{}'.format(action), mock.Mock(return_value=False)): response = self.put(decision) self.assertEqual(response.status_code, 500) self.assertEqual(response.data, RefundSerializer(self.refund).data)
def test_success(self, action): """ If the action succeeds, the view should return HTTP 200 and the serialized Refund. """ with mock.patch( 'ecommerce.extensions.refund.models.Refund.{}'.format(action), mock.Mock(return_value=True)): response = self.put(action) self.assertEqual(response.status_code, 200) self.assertEqual(response.data, RefundSerializer(self.refund).data)