Projet

Général

Profil

0001-misc-transform-Payment.payment_status-into-a-propert.patch

Benjamin Dauvergne, 29 janvier 2021 15:38

Télécharger (2,26 ko)

Voir les différences:

Subject: [PATCH] misc: transform Payment.payment_status into a property
 (#49148)

 eopayment/__init__.py      | 4 ++++
 eopayment/common.py        | 2 --
 tests/test_base_payment.py | 4 +---
 tests/test_payfip_ws.py    | 1 +
 4 files changed, 6 insertions(+), 5 deletions(-)
eopayment/__init__.py
238 238
        if not self.backend.payment_status:
239 239
            raise NotImplementedError('payment_status is not implemented on this backend')
240 240
        return self.backend.payment_status(transaction_id=transaction_id, **kwargs)
241

  
242
    @property
243
    def has_payment_status(self):
244
        return hasattr(self.backend, 'payment_status')
eopayment/common.py
196 196
            amount = amount.to_integral_value(ROUND_DOWN)
197 197
        return str(amount)
198 198

  
199
    payment_status = None
200

  
201 199

  
202 200
class Form(object):
203 201
    def __init__(self, url, method, fields, encoding='utf-8',
tests/test_base_payment.py
112 112

  
113 113
def test_payment_status(monkeypatch):
114 114
    _, payment = do_mock_backend(monkeypatch)
115

  
116
    with pytest.raises(NotImplementedError):
117
        payment.payment_status('whatever')
115
    assert not payment.has_payment_status
tests/test_payfip_ws.py
216 216

  
217 217
@set_history_name('test_get_info_paiement_P1')
218 218
def test_P1_and_payment_status(history, backend):
219
    assert backend.has_payment_status
219 220
    response = backend.payment_status(transaction_id='cc0cb210-1cd4-11ea-8cca-0213ad91a103')
220 221
    assert response.result == eopayment.EXPIRED
221 222

  
222
-