def test_request_fee_receipt(self, mock_send): """A receipt should be sent after request fee is paid.""" foia = FOIARequestFactory() mock_charge.metadata['action'] = 'request-fee' mock_charge.metadata['foia'] = foia.pk tasks.send_charge_receipt(mock_charge.id) mock_send.assert_called_with(fail_silently=False)
def test_receipt_recipients(self): """Receipt should be to the user and CC'd to their receipt emails""" ReceiptEmail.objects.create(user=self.user, email='*****@*****.**') ReceiptEmail.objects.create(user=self.user, email='*****@*****.**') mock_charge.metadata['action'] = 'unknown-charge' tasks.send_charge_receipt(mock_charge.id) eq_(len(mail.outbox), 1) eq_(mail.outbox[0].to, [self.user.email]) eq_(set(mail.outbox[0].cc), {'*****@*****.**', '*****@*****.**'})
def test_invoice_charge(self, mock_send): """A charge with an attachced invoice should not generate an email.""" mock_charge.invoice = mock_invoice.id mock_charge.metadata['action'] = 'unknown-charge' tasks.send_charge_receipt(mock_charge.id) mock_send.assert_not_called()
def test_other_receipt(self, mock_send): """A generic receipt should be sent for any other charges.""" mock_charge.metadata['action'] = 'unknown-charge' tasks.send_charge_receipt(mock_charge.id) mock_send.assert_called_with(fail_silently=False)
def test_crowdfund_payment_receipt(self, mock_send): """A receipt should be sent after a crowdfund payment is made.""" mock_charge.metadata['action'] = 'crowdfund-payment' tasks.send_charge_receipt(mock_charge.id) mock_send.assert_called_with(fail_silently=False)
def test_request_purchase_receipt(self, mock_send): """A receipt should be sent after request bundle is purchased.""" mock_charge.metadata['action'] = 'request-purchase' tasks.send_charge_receipt(mock_charge.id) mock_send.assert_called_with(fail_silently=False)