Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade python & django #58

Merged
merged 7 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions multidb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ class PinningReplicaRouter(ReplicaRouter):

"""
def db_for_read(self, model, **hints):
"""Send reads to replicas in round-robin unless this thread is "stuck" to
the master."""
"""Send reads to replicas in round-robin unless this thread is
"stuck" to the master."""
return DEFAULT_DB_ALIAS if this_thread_is_pinned() else get_replica()


Expand Down
6 changes: 5 additions & 1 deletion multidb/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,13 @@ class MiddlewareTests(UnpinningTestCase):
def setUp(self):
super(MiddlewareTests, self).setUp()

# Django 4.0 requires response as an arg
# https://stackoverflow.com/questions/62944755/how-to-unittest-new-style-django-middleware
get_response = mock.MagicMock()

# Every test uses these, so they're okay as attrs.
self.request = HttpRequest()
self.middleware = PinningRouterMiddleware()
self.middleware = PinningRouterMiddleware(get_response)

def test_pin_on_cookie(self):
"""Thread should pin when the cookie is set."""
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
django-nose==1.4.4
flake8==3.3.0
django-nose==1.4.7
flake8==6.0.0
4 changes: 2 additions & 2 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ usage() {

case "$1" in
"test" )
django-admin.py test multidb ;;
django-admin test multidb ;;
"shell" )
django-admin.py shell ;;
django-admin shell ;;
"check" )
flake8 multidb ;;
* )
Expand Down
10 changes: 9 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,34 @@ envlist =
{py36,py37,py38,py39}-3.0.X
{py36,py37,py38,py39}-3.1.X
{py36,py37,py38,py39}-3.2.X
{py38,py39,py310}-4.0.X
{py38,py39,py310}-4.1.X
{py38,py39,py310}-4.2.X

[testenv]
allowlist_externals=./run.sh
basepython =
py35: python3.5
py36: python3.6
py37: python3.7
py38: python3.8
py39: python3.9
py10: python3.10

commands =
./run.sh test
python --version
django-admin.py --version
django-admin --version
pip freeze

deps =
2.2.X: Django>=2.2,<2.3
3.0.X: Django>=3.0,<3.1
3.1.X: Django>=3.1,<3.2
3.2.X: Django>=3.2,<4.0
4.0.X: Django>=4.0,<4.1
4.1.X: Django>=4.1,<4.2
4.2.X: Django>=4.2,<5.0
-r{toxinidir}/requirements.txt

[testenv:flake8]
Expand Down