misc: transform Payment.payment_status into a property (#49148)

This commit is contained in:
Benjamin Dauvergne 2020-12-05 09:16:30 +01:00
parent 715b7555f2
commit dbb2301eb5
4 changed files with 6 additions and 5 deletions

View File

@ -238,3 +238,7 @@ class Payment(object):
if not self.backend.payment_status:
raise NotImplementedError('payment_status is not implemented on this backend')
return self.backend.payment_status(transaction_id=transaction_id, **kwargs)
@property
def has_payment_status(self):
return hasattr(self.backend, 'payment_status')

View File

@ -196,8 +196,6 @@ class PaymentCommon(object):
amount = amount.to_integral_value(ROUND_DOWN)
return str(amount)
payment_status = None
class Form(object):
def __init__(self, url, method, fields, encoding='utf-8',

View File

@ -112,6 +112,4 @@ def test_get_parameters(monkeypatch):
def test_payment_status(monkeypatch):
_, payment = do_mock_backend(monkeypatch)
with pytest.raises(NotImplementedError):
payment.payment_status('whatever')
assert not payment.has_payment_status

View File

@ -216,6 +216,7 @@ def test_get_info_paiement_P1(payfip, freezer):
@set_history_name('test_get_info_paiement_P1')
def test_P1_and_payment_status(history, backend):
assert backend.has_payment_status
response = backend.payment_status(transaction_id='cc0cb210-1cd4-11ea-8cca-0213ad91a103')
assert response.result == eopayment.EXPIRED