Skip to content

Commit 45738e8

Browse files
author
Alexey Semashkevich
committed
Fix default_app_config warning
1 parent 14e3e25 commit 45738e8

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
default_app_config = "django_postgres_hot_upgrade.app.PostgresHotUpgradeConfig"
1+
import django
2+
3+
if django.VERSION[:2] < (3, 2):
4+
default_app_config = "django_postgres_hot_upgrade.apps.PostgresHotUpgradeConfig"

tests/test_unit.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import pytest
22
from django.db.backends import signals as django_signals
33

4-
from django_postgres_hot_upgrade import app
4+
from django_postgres_hot_upgrade import apps
55

66

77
@pytest.fixture(autouse=True)
88
def module_cache():
9-
app._version_cache = {}
9+
apps._version_cache = {}
1010
yield
11-
app._version_cache = {}
11+
apps._version_cache = {}
1212

1313

1414
@pytest.mark.parametrize(
@@ -21,7 +21,7 @@ def module_cache():
2121
)
2222
def test_should_run(mocker, vendor, alias, expected):
2323
connection = mocker.Mock(vendor=vendor, alias=alias)
24-
assert app._should_run(connection) is expected
24+
assert apps._should_run(connection) is expected
2525

2626

2727
def test_config_ready():
@@ -39,35 +39,35 @@ def fake_connection(mocker):
3939

4040

4141
def test_on_connect_should_not_run(fake_connection, mocker):
42-
clear = mocker.patch("django_postgres_hot_upgrade.app._clear")
42+
clear = mocker.patch("django_postgres_hot_upgrade.apps._clear")
4343
fake_connection = mocker.Mock(vendor="mysql", alias="default")
44-
app._on_connect(connection=fake_connection)
44+
apps._on_connect(connection=fake_connection)
4545
clear.assert_not_called()
4646

4747

4848
def test_on_connect_first_call(fake_connection, mocker):
49-
clear = mocker.patch("django_postgres_hot_upgrade.app._clear")
49+
clear = mocker.patch("django_postgres_hot_upgrade.apps._clear")
5050
fake_connection.connection.server_version = 100000
51-
app._on_connect(connection=fake_connection)
52-
assert app._version_cache == {"default": 100000}
51+
apps._on_connect(connection=fake_connection)
52+
assert apps._version_cache == {"default": 100000}
5353
clear.assert_called()
5454

5555

5656
def test_on_connect_second_call_same_version(fake_connection, mocker):
57-
clear = mocker.patch("django_postgres_hot_upgrade.app._clear")
57+
clear = mocker.patch("django_postgres_hot_upgrade.apps._clear")
5858
fake_connection.connection.server_version = 100000
59-
app._on_connect(connection=fake_connection)
59+
apps._on_connect(connection=fake_connection)
6060
clear.reset_mock()
61-
app._on_connect(connection=fake_connection)
61+
apps._on_connect(connection=fake_connection)
6262
clear.assert_not_called()
6363

6464

6565
def test_on_connect_second_call_different_version(fake_connection, mocker):
66-
clear = mocker.patch("django_postgres_hot_upgrade.app._clear")
66+
clear = mocker.patch("django_postgres_hot_upgrade.apps._clear")
6767
fake_connection.connection.server_version = 100000
68-
app._on_connect(connection=fake_connection)
68+
apps._on_connect(connection=fake_connection)
6969
fake_connection.connection.server_version = 120000
7070
clear.reset_mock()
71-
app._on_connect(connection=fake_connection)
72-
assert app._version_cache == {"default": 120000}
71+
apps._on_connect(connection=fake_connection)
72+
assert apps._version_cache == {"default": 120000}
7373
clear.assert_called()

0 commit comments

Comments
 (0)