def test_refund_completed_email(self, solitude): solitude.api.bango.refund.post.return_value = self.bango_ret(COMPLETED) solitude.get.return_value = self.refund_tx_ret() transaction_refund(self.req, self.uuid) eq_(len(mail.outbox), 1) assert self.app.name.localized_string in smart_str(mail.outbox[0].body)
def test_manual_refund(self, client): req = self.request({'refund_reason': 'text', 'manual': True}) transaction_refund(req, self.uuid) client.api.bango.refund.post.assert_called_with({ 'uuid': '123', 'manual': True })
def test_fake_refund(self, client): req = self.request({'refund_reason': 'text', 'fake': 'OK'}) with self.settings(BANGO_FAKE_REFUNDS=True): transaction_refund(req, self.uuid) client.api.bango.refund.post.assert_called_with({ 'fake_response_status': {'responseCode': 'OK'}, 'uuid': '123', 'manual': False})
def test_refund_pending_email(self, solitude): solitude.api.bango.refund.post.return_value = ( {'status': STATUS_PENDING}) transaction_refund(self.req, self.uuid) eq_(len(mail.outbox), 1) assert self.app.name.localized_string in smart_str(mail.outbox[0].body)
def test_refund_slumber_error(self, solitude): for exception in (exceptions.HttpClientError, exceptions.HttpServerError): solitude.api.bango.refund.post.side_effect = exception res = transaction_refund(self.req, self.uuid) eq_(self.contrib.has_refund(), False) self.assert3xx(res, self.summary_url)
def test_refund_slumber_error(self, solitude): for exception in (exceptions.HttpClientError, exceptions.HttpServerError): solitude.api.bango.refund.post.side_effect = exception res = transaction_refund(self.req, self.uuid) # Check no refund Contributions created. assert not self.contrib.get_refund_contribs().exists() self.assert3xx(res, self.summary_url)
def test_refund_failed(self, solitude): solitude.api.bango.refund.post.return_value = self.bango_ret(FAILED) res = transaction_refund(self.req, self.uuid) # Check no refund Contributions created. assert not self.contrib.get_refund_contribs().exists() self.assert3xx(res, self.summary_url)
def test_refund_success(self, solitude): solitude.api.bango.refund.post.return_value = ({ 'status': STATUS_PENDING}) res = transaction_refund(self.req, self.uuid) refund = Refund.objects.filter(contribution__addon=self.app) eq_(refund.count(), 1) eq_(refund[0].status, amo.REFUND_PENDING) assert self.req.POST['refund_reason'] in refund[0].refund_reason self.assert3xx(res, self.summary_url)
def test_already_refunded(self, solitude): solitude.api.bango.refund.post.return_value = self.bango_ret(PENDING) solitude.get.return_value = self.refund_tx_ret() res = transaction_refund(self.req, self.uuid) refund_count = Contribution.objects.all().count() # Check no refund Contributions created. res = self.client.post(self.url, {"refund_reason": "text"}) assert refund_count == Contribution.objects.all().count() self.assert3xx(res, reverse("lookup.transaction_summary", args=[self.uuid]))
def test_already_refunded(self, solitude): solitude.api.bango.refund.post.return_value = self.bango_ret(PENDING) solitude.get.return_value = self.refund_tx_ret() res = transaction_refund(self.req, self.uuid) refund_count = Contribution.objects.all().count() # Check no refund Contributions created. res = self.client.post(self.url, {'refund_reason': 'text'}) assert refund_count == Contribution.objects.all().count() self.assert3xx(res, reverse('lookup.transaction_summary', args=[self.uuid]))
def test_refund_success(self, solitude): solitude.api.bango.refund.post.return_value = self.bango_ret(PENDING) solitude.get.return_value = self.refund_tx_ret() # Do refund. res = transaction_refund(self.req, self.uuid) refund = Refund.objects.filter(contribution__addon=self.app) refund_contribs = self.contrib.get_refund_contribs() # Check Refund created. assert refund.exists() eq_(refund[0].status, amo.REFUND_PENDING) assert self.req.POST['refund_reason'] in refund[0].refund_reason # Check refund Contribution created. eq_(refund_contribs.exists(), True) eq_(refund_contribs[0].refund, refund[0]) eq_(refund_contribs[0].related, self.contrib) eq_(refund_contribs[0].amount, -self.contrib.amount) self.assert3xx(res, self.summary_url)
def test_fake_refund(self, client): req = self.request({"refund_reason": "text", "fake": "OK"}) with self.settings(BANGO_FAKE_REFUNDS=True): transaction_refund(req, self.uuid) client.api.bango.refund.post.assert_called_with({"fake_response_status": {"responseCode": "OK"}, "uuid": "123"})
def test_fake_refund_ignored(self, client): req = self.request({'refund_reason': 'text', 'fake': 'OK'}) with self.settings(BANGO_FAKE_REFUNDS=False): transaction_refund(req, self.uuid) client.api.bango.refund.post.assert_called_with({'uuid': '123'})
def test_refund_failed(self, solitude): solitude.api.bango.refund.post.return_value = ( {'status': STATUS_FAILED}) res = transaction_refund(self.req, self.uuid) eq_(self.contrib.has_refund(), False) self.assert3xx(res, self.summary_url)
def test_fake_refund_ignored(self, client): req = self.request({"refund_reason": "text", "fake": "OK"}) with self.settings(BANGO_FAKE_REFUNDS=False): transaction_refund(req, self.uuid) client.api.bango.refund.post.assert_called_with({"uuid": "123"})
def test_manual_refund(self, client): req = self.request({'refund_reason': 'text', 'manual': True}) transaction_refund(req, self.uuid) client.api.bango.refund.post.assert_called_with( {'uuid': '123', 'manual': True})