Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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
     })
Exemplo n.º 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})
Exemplo n.º 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})
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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]))
Exemplo n.º 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]))
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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"})
Exemplo n.º 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'})
Exemplo n.º 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'})
Exemplo n.º 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)
Exemplo n.º 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"})
Exemplo n.º 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})