Skip to content

Commit

Permalink
Update supported versions of Python and Django (#432)
Browse files Browse the repository at this point in the history
* Python&Django version upgrades

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
mariofix and pre-commit-ci[bot] authored Dec 19, 2024
1 parent 2b2591e commit 7e9bcf1
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 54 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
fail-fast: false
max-parallel: 5
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
django-version: ['3.2', '4.1', '4.2', '5.0', '5.1', 'main']
python-version: ['3.9', '3.10', '3.11', '3.12']
django-version: ['4.2', '5.0', '5.1', 'main']

steps:
- uses: actions/checkout@v2
Expand Down
92 changes: 54 additions & 38 deletions payments/mercadopago/test_mercadopago.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,17 @@ def test_approved_payment_notification(rf, mp_provider: MercadoPagoProvider):
"status": 200,
}

with patch(
"mercadopago.resources.payment.Payment.get",
spec=True,
return_value=payment_info_response,
) as payment_info, patch(
"payments.mercadopago.redirect",
spec=True,
) as redirect:
with (
patch(
"mercadopago.resources.payment.Payment.get",
spec=True,
return_value=payment_info_response,
) as payment_info,
patch(
"payments.mercadopago.redirect",
spec=True,
) as redirect,
):
rv = mp_provider.process_data(payment, request)

assert payment_info.call_count == 1
Expand All @@ -232,13 +235,16 @@ def test_create_preference_failure(mp_provider: MercadoPagoProvider):

payment = Payment()

with patch(
"mercadopago.resources.preference.Preference.create",
spec=True,
return_value=preference_info,
), pytest.raises(
PaymentError,
match="Failed to create MercadoPago preference.",
with (
patch(
"mercadopago.resources.preference.Preference.create",
spec=True,
return_value=preference_info,
),
pytest.raises(
PaymentError,
match="Failed to create MercadoPago preference.",
),
):
mp_provider.create_preference(payment)

Expand Down Expand Up @@ -266,13 +272,16 @@ def test_process_failed_collection(mp_provider: MercadoPagoProvider):
}

payment = Payment()
with patch(
"mercadopago.resources.payment.Payment.get",
spec=True,
return_value=payment_info,
), pytest.raises(
PaymentError,
match="MercadoPago sent invalid payment data.",
with (
patch(
"mercadopago.resources.payment.Payment.get",
spec=True,
return_value=payment_info,
),
pytest.raises(
PaymentError,
match="MercadoPago sent invalid payment data.",
),
):
mp_provider.process_collection(payment, "12")

Expand Down Expand Up @@ -331,12 +340,13 @@ def test_get_preference_internal_error(mp_provider: MercadoPagoProvider):

payment = Payment()
payment.transaction_id = "ABJ122"
with patch(
"mercadopago.resources.preference.Preference.get",
spec=True,
return_value=mocked_response,
) as get_preference, pytest.raises(
PaymentError, match="Failed to retrieve MercadoPago preference."
with (
patch(
"mercadopago.resources.preference.Preference.get",
spec=True,
return_value=mocked_response,
) as get_preference,
pytest.raises(PaymentError, match="Failed to retrieve MercadoPago preference."),
):
mp_provider.get_preference(payment)

Expand Down Expand Up @@ -365,11 +375,14 @@ def test_get_form_for_existing_preference(

payment = Payment()
payment.transaction_id = "ABJ122"
with patch(
"mercadopago.resources.preference.Preference.get",
spec=True,
return_value=mocked_response,
) as get_preference, pytest.raises(RedirectNeeded) as exc_info:
with (
patch(
"mercadopago.resources.preference.Preference.get",
spec=True,
return_value=mocked_response,
) as get_preference,
pytest.raises(RedirectNeeded) as exc_info,
):
mp_provider.get_form(payment)

assert get_preference.call_count == 1
Expand All @@ -387,11 +400,14 @@ def test_get_form_for_inexistent_preference(mp_provider: MercadoPagoProvider):
}

payment = Payment()
with patch(
"mercadopago.resources.preference.Preference.create",
spec=True,
return_value=mocked_response,
) as get_preference, pytest.raises(RedirectNeeded) as exc_info:
with (
patch(
"mercadopago.resources.preference.Preference.create",
spec=True,
return_value=mocked_response,
) as get_preference,
pytest.raises(RedirectNeeded) as exc_info,
):
mp_provider.get_form(payment)

assert get_preference.call_count == 1
Expand Down
2 changes: 1 addition & 1 deletion payments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import json
import logging
from typing import Iterable
from collections.abc import Iterable
from uuid import uuid4

from django.db import models
Expand Down
10 changes: 4 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,28 @@ authors = [
]
description = "Universal payment handling for Django"
readme = "README.rst"
requires-python = ">=3.7"
requires-python = ">=3.9"
keywords = ["payments"]
license = {text = "BSD"}
classifiers = [
"Environment :: Web Environment",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.1",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.0",
"Framework :: Django :: 5.1",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Framework :: Django",
"Topic :: Software Development :: Libraries :: Application Frameworks",
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = [
"Django>=3.2",
"Django>=4.2",
"requests>=1.2.0",
"django-phonenumber-field[phonenumberslite]>=5.0.0",
]
Expand Down Expand Up @@ -89,7 +87,7 @@ DJANGO_SETTINGS_MODULE = "test_settings"
pythonpath = "."

[tool.ruff]
target-version = "py38"
target-version = "py39"

[tool.ruff.lint]
select = [
Expand Down
8 changes: 1 addition & 7 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[tox]
envlist =
py{38,39}-dj32
py{38,39,310,311}-dj{41,42}
py{39,310,311}-dj{42}
py{311,312}-dj{50,51}
py{310,311,312}-djmain
skip_missing_interpreters = true
Expand All @@ -13,8 +12,6 @@ ignore_outcome =
ignore_errors =
djmain: True
deps=
dj32: Django>=3.2,<3.3
dj41: Django>=4.1,<4.2
dj42: Django>=4.2,<5.0
dj50: Django>=5.0,<5.1
dj51: Django>=5.1,<5.2
Expand All @@ -33,7 +30,6 @@ commands=

[gh-actions]
python =
3.8: py38
3.9: py39
3.10: py310
3.11: py311
Expand All @@ -48,8 +44,6 @@ commands = mypy .

[gh-actions:env]
DJANGO =
3.2: dj32
4.1: dj41
4.2: dj42
5.0: dj50
5.1: dj51
Expand Down

0 comments on commit 7e9bcf1

Please sign in to comment.