Example #1
0
    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)
Example #2
0
    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)
Example #3
0
 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
     })
Example #4
0
 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})
Example #5
0
 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})
Example #6
0
    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)
Example #7
0
 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)
Example #8
0
    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)
Example #9
0
    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)
Example #10
0
    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)
Example #11
0
    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)
Example #12
0
    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)
Example #13
0
    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]))
Example #14
0
    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]))
Example #15
0
    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)
Example #16
0
    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)
Example #17
0
 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"})
Example #18
0
 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'})
Example #19
0
 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'})
Example #20
0
 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)
Example #21
0
 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"})
Example #22
0
 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})