Skip to content

Commit

Permalink
Update Django and Python supported versions
Browse files Browse the repository at this point in the history
  • Loading branch information
pfouque committed Jan 28, 2024
1 parent d4cc292 commit 1aad9e7
Show file tree
Hide file tree
Showing 25 changed files with 58 additions and 70 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
CHANGELOG
=========

Unreleased
------------------

* Add support for django 4.1, 4.2, and django 5.0
* Add support for Python 3.10, 3.11, and 3.12
* Remove support for django 2.2 and 3.0
* Remove support for Python 3.6, 3.7

0.5.0 (2021-12-27)
------------------

Expand Down
11 changes: 5 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# django-sendsms documentation build configuration file, created by
# sphinx-quickstart on Sun Aug 21 17:29:36 2011.
Expand Down Expand Up @@ -47,8 +46,8 @@
master_doc = "index"

# General information about the project.
project = u"django-sendsms"
copyright = u"2011, Stefan Foulis"
project = "django-sendsms"
copyright = "2011, Stefan Foulis"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -188,8 +187,8 @@
(
"index",
"django-sendsms.tex",
u"django-sendsms Documentation",
u"Stefan Foulis",
"django-sendsms Documentation",
"Stefan Foulis",
"manual",
)
]
Expand Down Expand Up @@ -223,5 +222,5 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
("index", "django-sendsms", u"django-sendsms Documentation", [u"Stefan Foulis"], 1)
("index", "django-sendsms", "django-sendsms Documentation", ["Stefan Foulis"], 1)
]
1 change: 0 additions & 1 deletion sendsms/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
__version_info__ = {
"major": 0,
"minor": 5,
Expand Down
11 changes: 2 additions & 9 deletions sendsms/api.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
# -*- coding: utf-8 -*-
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured

try:
# Django versions >= 1.9
from django.utils.module_loading import import_module
except ImportError:
# Django versions < 1.9
from django.utils.importlib import import_module
from django.utils.module_loading import import_module


def send_sms(
Expand Down Expand Up @@ -75,7 +68,7 @@ def get_connection(path=None, fail_silently=False, **kwargs):
mod = import_module(mod_name)
except AttributeError as e:
raise ImproperlyConfigured(
u'Error importing sms backend module %s: "%s"' % (mod_name, e)
'Error importing sms backend module %s: "%s"' % (mod_name, e)
)

try:
Expand Down
1 change: 0 additions & 1 deletion sendsms/backends/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
# -*- coding: utf-8 -*-
3 changes: 0 additions & 3 deletions sendsms/backends/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-


class BaseSmsBackend(object):
"""
Base class for sms backend implementations.
Expand Down
2 changes: 0 additions & 2 deletions sendsms/backends/bulksms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

from django.conf import settings

import requests
Expand Down
1 change: 1 addition & 0 deletions sendsms/backends/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"""

from __future__ import absolute_import

from django.conf import settings
Expand Down
4 changes: 2 additions & 2 deletions sendsms/backends/console.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
"""
SMS backend that writes messages to console instead of sending them.
This is a total ripoff of django.core.mail.backends.console
"""

import sys
import threading

Expand Down Expand Up @@ -43,7 +43,7 @@ def send_messages(self, messages):


def render_message(message):
return u"""from: %(from)s\nto: %(to)s\nflash: %(flash)s\n%(body)s""" % {
return """from: %(from)s\nto: %(to)s\nflash: %(flash)s\n%(body)s""" % {
"from": message.from_phone,
"to": ", ".join(message.to),
"flash": message.flash,
Expand Down
1 change: 0 additions & 1 deletion sendsms/backends/dummy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Dummy sms backend that does nothing.
"""
Expand Down
1 change: 0 additions & 1 deletion sendsms/backends/esendex.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Esendex sms gateway backend. (http://www.esendex.es/)
Expand Down
1 change: 0 additions & 1 deletion sendsms/backends/locmem.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Backend for test environment.
"""
Expand Down
1 change: 0 additions & 1 deletion sendsms/backends/nexmo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
nexmo sms gateway backend. (https://www.nexmo.com/)
Expand Down
6 changes: 1 addition & 5 deletions sendsms/backends/ovhsms.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
try:
from urllib.parse import urlencode
except ImportError:
from urllib import urlencode # Python2
import json
import logging
from urllib.parse import urlencode

from django.conf import settings

Expand Down Expand Up @@ -38,7 +35,6 @@ def _send_via_ovh(
tag=None, # string of max 20 characters
deferred=None,
): # eg. format "125025112017" for sending on 28/11/2017 at 12h50

# late lookup, else tests won't work...
OVH_API_URL = getattr(
settings, "OVH_API_URL", "https://www.ovh.com/cgi-bin/sms/http2sms.cgi"
Expand Down
1 change: 1 addition & 0 deletions sendsms/backends/rq.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"""

from django.conf import settings
from django.core.exceptions import ImproperlyConfigured

Expand Down
1 change: 1 addition & 0 deletions sendsms/backends/smsglobal.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""SMS Global sms backend class."""

import logging
import math
import re
Expand Down
2 changes: 0 additions & 2 deletions sendsms/backends/smspubli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""
SmsPubli sms gateway backend. (http://www.smspubli.com)
Expand Down
3 changes: 1 addition & 2 deletions sendsms/backends/twiliorest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-

"""
this backend requires the twilio python library: http://pypi.python.org/pypi/twilio/
"""

from django.conf import settings

import twilio
Expand Down
1 change: 0 additions & 1 deletion sendsms/message.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from django.conf import settings

from sendsms.api import get_connection
Expand Down
1 change: 0 additions & 1 deletion sendsms/signals.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from django.dispatch import Signal

sms_post_send = Signal() # providing_args=["from_phone", "to", "body"]
3 changes: 1 addition & 2 deletions sendsms/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
try:
from importlib import import_module
except ImportError:
from django.utils.importlib import import_module
from django.utils.module_loading import import_module


def load_object(import_path):
Expand Down
11 changes: 11 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,21 @@
classifiers=[
"Development Status :: 5 - Production/Stable",
"Framework :: Django",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.0",
"Framework :: Django :: 4.1",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.0",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"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",
"Topic :: Internet :: WWW/HTTP",
],
)
25 changes: 8 additions & 17 deletions test.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
# -*- coding: utf-8 -*-

try:
from unittest import mock
except:
import mock

try:
from importlib import reload
except:
pass

import unittest
from unittest import mock

from django.conf import settings
from django.test import SimpleTestCase

import sendsms

try:
from importlib import reload
except:
pass

if not settings.configured:
settings.configure(
SENDSMS_BACKEND="sendsms.backends.locmem.SmsBackend",
Expand All @@ -40,8 +34,8 @@ def test_send_simple_sms(self):
self.assertEqual(len(sendsms.outbox), 1)

def test_send_esendex_sandbox(self):
from sendsms.message import SmsMessage
from sendsms.api import get_connection
from sendsms.message import SmsMessage

connection = get_connection("sendsms.backends.esendex.SmsBackend")
obj = SmsMessage(
Expand Down Expand Up @@ -159,7 +153,6 @@ def test_should_call_proper_url(self, _call_url_mock):
OVH_API_FROM="mysender",
OVH_API_NO_STOP=False,
):

message = SmsMessage(
body="Hello!",
from_phone="29290", # overrides OVH_API_FROM
Expand All @@ -182,7 +175,6 @@ def test_should_call_proper_url(self, _call_url_mock):
OVH_API_PASSWORD="mypwd",
OVH_API_FROM="mysender",
):

message = SmsMessage(
body="Wêlcome à vous\nHenrï & Jack!\r\n",
from_phone="thierry", # overrides OVH_API_FROM
Expand All @@ -206,10 +198,9 @@ def test_should_properly_handle_errors(self):
OVH_API_PASSWORD="mypwd",
OVH_API_FROM="mysender",
):

from sendsms.api import send_sms

with self.assertRaisesRegex(RuntimeError, "Invalid smsAccount"):
with self.assertRaises(RuntimeError):
send_sms(body="I can hàz txt", from_phone=None, to=["+33632020000"])

res = send_sms(
Expand Down
22 changes: 13 additions & 9 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
[tox]
envlist =
py{36,37}-dj{22}
py{37,38}-dj{30}
py{37,38,39}-dj{32}
py{38,39}-dj{40}
py{38,39}-dj32
py{38,39,310}-dj40
py{38,39,310,311}-dj41
py{38,39,310,311,312}-dj42
py{310,311,312}-dj50
flake8
black

[gh-actions]
python =
3.6: py36, black, flake8
3.7: py37, black, flake8
3.8: py38, black, flake8
3.9: py39, black, flake8
3.10: py310, black, flake8
3.11: py311, black, flake8
3.12: py312, black, flake8

[testenv]
commands =
Expand All @@ -21,10 +23,12 @@ commands =
coverage report
deps =
coverage
dj22: Django~=2.2.0
dj30: Django~=3.0.0
setuptools
dj32: Django~=3.2.0
dj40: Django~=4.0rc1
dj40: Django~=4.0.0
dj41: Django~=4.1.0
dj42: Django~=4.2.0
dj50: Django~=5.0.0

[testenv:flake8]
commands = flake8 sendsms setup.py
Expand Down

0 comments on commit 1aad9e7

Please sign in to comment.