From c7b59804365c309dd07d115c6abdab1f54e20d45 Mon Sep 17 00:00:00 2001 From: NyanKiyoshi Date: Wed, 11 Sep 2019 14:03:22 +0200 Subject: [PATCH 1/2] Fixed tests against latest pytest version --- .travis.yml | 17 ++++++----------- tests/test_forms.py | 6 +++--- tests/test_provider.py | 11 ++++++++--- tox.ini | 6 +++--- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index f7255b4..f53bc2d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,7 @@ python: - "3.6" env: - DJANGO="1.11" - - DJANGO="2.0" - - DJANGO="2.1" + - DJANGO="2.2" - DJANGO="master" matrix: include: @@ -16,35 +15,31 @@ matrix: - python: "3.7" sudo: required dist: xenial - env: DJANGO="2.0" - - python: "3.7" - sudo: required - dist: xenial - env: DJANGO="2.1" + env: DJANGO="2.2" - python: "3.7" sudo: required dist: xenial env: DJANGO="master" allow_failures: - python: "3.5" - env: DJANGO="2.1" + env: DJANGO="2.2" - python: "3.5" env: DJANGO="master" - python: "3.6" - env: DJANGO="2.1" + env: DJANGO="2.2" - python: "3.6" env: DJANGO="master" - python: "3.7" sudo: required dist: xenial - env: DJANGO="2.1" + env: DJANGO="2.2" - python: "3.7" env: DJANGO="master" sudo: required dist: xenial exclude: - python: "3.4" - env: DJANGO="2.1" + env: DJANGO="2.2" - python: "3.4" env: DJANGO="master" after_success: codecov diff --git a/tests/test_forms.py b/tests/test_forms.py index 0fac558..20fdaf1 100644 --- a/tests/test_forms.py +++ b/tests/test_forms.py @@ -25,11 +25,11 @@ def test_modal_payment_form_already_processed( provider.razorpay_client.payment.capture.assert_not_called() -def test_modal_payment_form_invalid_data( - provider, payment, valid_payment_form_data): +def test_modal_payment_form_invalid_data(provider, payment): form = ModalPaymentForm( provider=provider, payment=payment, data={}) - with pytest.raises(KeyError, message='razorpay_payment_id'): + with pytest.raises(KeyError) as exc: form.is_valid() + assert exc.value.args == ('razorpay_payment_id',) provider.razorpay_client.payment.capture.assert_not_called() diff --git a/tests/test_provider.py b/tests/test_provider.py index a1a46de..b50a9f5 100644 --- a/tests/test_provider.py +++ b/tests/test_provider.py @@ -28,17 +28,21 @@ def test_get_form(mocked_razor_checkout, provider, payment): def test_get_form_invalid_data(provider, payment): - with pytest.raises(KeyError, message='razorpay_payment_id'): + with pytest.raises(KeyError) as exc: provider.get_form(payment, data={}) + assert exc.value.args == ('razorpay_payment_id',) + assert payment.captured_amount == 0 assert payment.transaction_id is None def test_get_form_valid_data(valid_payment_form_data, provider, payment): - with pytest.raises(RedirectNeeded, message='https://success'): + with pytest.raises(RedirectNeeded) as exc: provider.get_form(payment, data=valid_payment_form_data) + assert exc.value.args[0] == payment.get_success_url() + assert payment.save.call_count != 0 assert payment.status == PaymentStatus.CONFIRMED assert payment.captured_amount == payment.total @@ -84,7 +88,8 @@ def _raise_fake_error(*args, **kwargs): payment.captured_amount = payment.total provider.razorpay_client.payment.refund.side_effect = _raise_fake_error - with pytest.raises(ValueError, message='hello world'): + with pytest.raises(ValueError) as exc: provider.refund(payment, Decimal(2220)) + assert str(exc.value.args) == str(('hello world',)) assert payment.captured_amount == payment.total diff --git a/tox.ini b/tox.ini index 638b9e5..732e1f6 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27-django111, py{34,35,36,37}-django{111,20,21,_master} +envlist = py27-django111, py{34,35,36,37}-django{111,20,22,_master} [testenv] usedevelop=True @@ -7,7 +7,7 @@ deps= coverage django111: django>=1.11a1,<1.12 django20: Django>=2.0a1,<2.1 - django21: Django>=2.1,<2.2 + django22: Django>=2.2,<2.3 django_master: https://github.com/django/django/archive/master.tar.gz mock pytest @@ -27,5 +27,5 @@ unignore_outcomes = True DJANGO = 1.11: django111 2.0: django2.0 - 2.1: django2.1 + 2.2: django2.2 master: django_master From ca626a34d1e2655cf194a7f782caaf72a9837ce3 Mon Sep 17 00:00:00 2001 From: NyanKiyoshi Date: Wed, 11 Sep 2019 14:06:41 +0200 Subject: [PATCH 2/2] Bump version to 1.0 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 6d5e855..e529470 100755 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ description='Razorpay provider for django-payments.', long_description=long_description, long_description_content_type='text/markdown', - version='0.1.2', + version='1.0', packages=['django_payments_razorpay'], include_package_data=True, classifiers=[