def test_failed_invoice_charge(self, mock_send): """Make sure the send method is called for a failed payment notification""" tasks.failed_payment(mock_invoice.id) mock_send.assert_called_with(fail_silently=False) self.profile.refresh_from_db() ok_(self.profile.payment_failed, 'The payment failed flag should be raised.')
def test_last_attempt_pro(self, mock_cancel, mock_send): """After the last attempt at payment, cancel the user's pro subscription""" self.profile.payment_failed = True self.profile.save() ok_(self.profile.payment_failed, 'The payment failed flag should be raised.') mock_invoice.attempt_count = 4 mock_invoice.lines.data[0].plan.id = 'pro' tasks.failed_payment(mock_invoice.id) self.profile.refresh_from_db() mock_cancel.assert_called_with() mock_send.assert_called_with(fail_silently=False) ok_(not self.profile.payment_failed, 'The payment failed flag should be lowered.')