Skip to content

Commit

Permalink
Merge pull request #60 from openedx/zshkoor/django42
Browse files Browse the repository at this point in the history
feat: Added support for Django 4.2
  • Loading branch information
zubairshakoorarbisoft authored Jul 25, 2023
2 parents 3a0cb1c + a7e36e9 commit c6d58ec
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
matrix:
os: [ubuntu-20.04]
python-version: ['3.8']
toxenv: [quality, django32]
toxenv: [quality, django32, django42]

steps:
- uses: actions/checkout@v2
Expand All @@ -34,3 +34,4 @@ jobs:
env:
TOXENV: ${{ matrix.toxenv }}
run: tox

2 changes: 1 addition & 1 deletion release_util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
a collection of Django management commands used for analyzing and manipulating migrations.
"""

__version__ = '1.2.0' # pragma: no cover
__version__ = '1.3.0' # pragma: no cover
28 changes: 28 additions & 0 deletions release_util/tests/migrations/test_migrations/0004_fourth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 4.2.3 on 2023-07-24 11:29

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('release_util', '0003_third'),
]

operations = [
migrations.AlterField(
model_name='author',
name='id',
field=models.AutoField(primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='book',
name='id',
field=models.AutoField(primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='bookstore',
name='id',
field=models.AutoField(primary_key=True, serialize=False),
),
]
50 changes: 50 additions & 0 deletions release_util/tests/test_migration_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ def test_showmigrations_list(self):
{'app': 'release_util', 'migration': '0001_initial'},
{'app': 'release_util', 'migration': '0002_second'},
{'app': 'release_util', 'migration': '0003_third'},
{'app': 'release_util', 'migration': '0004_fourth'},
]
},
exit_value=exit_code
Expand All @@ -201,6 +202,7 @@ def test_showmigrations_list(self):
'migrations': [
{'app': 'release_util', 'migration': '0002_second'},
{'app': 'release_util', 'migration': '0003_third'},
{'app': 'release_util', 'migration': '0004_fourth'},
]
},
exit_value=exit_code
Expand All @@ -220,13 +222,33 @@ def test_showmigrations_list(self):
'initial_states': [{'app': 'release_util', 'migration': '0002_second'}],
'migrations': [
{'app': 'release_util', 'migration': '0003_third'},
{'app': 'release_util', 'migration': '0004_fourth'},
]
},
exit_value=exit_code
)

call_command("migrate", "release_util", "0003", verbosity=0)

for fail_on_unapplied, exit_code in (
(True, 1),
(False, 0),
):
self._check_command_output(
cmd="show_unapplied_migrations",
cmd_kwargs={'fail_on_unapplied': fail_on_unapplied},
output={
'database': 'default',
'initial_states': [{'app': 'release_util', 'migration': '0003_third'}],
'migrations': [
{'app': 'release_util', 'migration': '0004_fourth'},
]
},
exit_value=exit_code
)

call_command("migrate", "release_util", "0004", verbosity=0)

for fail_on_unapplied, exit_code in (
(True, 0),
(False, 0),
Expand Down Expand Up @@ -283,6 +305,7 @@ def test_run_migrations_success_one_by_one(self):
- [release_util, 0001_initial]
- [release_util, 0002_second]
- [release_util, 0003_third]
- [release_util, 0004_fourth]
initial_states:
- [release_util, zero]
"""
Expand All @@ -304,6 +327,11 @@ def test_run_migrations_success_one_by_one(self):
'duration': None,
'output': None
},
{
'migration': ['release_util', '0004_fourth'],
'duration': None,
'output': None
},
],
'failure': None,
'unapplied': [],
Expand Down Expand Up @@ -349,6 +377,7 @@ def test_run_migrations_success(self):
- [release_util, 0001_initial]
- [release_util, 0002_second]
- [release_util, 0003_third]
- [release_util, 0004_fourth]
initial_states:
- [release_util, zero]
"""
Expand All @@ -363,6 +392,7 @@ def test_run_migrations_success(self):
['release_util', '0001_initial'],
['release_util', '0002_second'],
['release_util', '0003_third'],
['release_util', '0004_fourth'],
],
'traceback': None,
'succeeded': True,
Expand Down Expand Up @@ -441,6 +471,25 @@ def test_run_migrations_success(self):
}
],
),
(
'0004_fourth',
[
{
'database': 'default',
'failed_migration': ['release_util', '0004_fourth'],
'migration': 'all',
'succeeded_migrations': [
['release_util', '0001_initial'],
['release_util', '0002_second'],
['release_util', '0003_third'],
],
'duration': None,
'output': None,
'traceback': None,
'succeeded': False,
}
],
),
)
@ddt.unpack
def test_run_migrations_failure(self, migration_name, migration_output):
Expand All @@ -457,6 +506,7 @@ def test_run_migrations_failure(self, migration_name, migration_output):
- [release_util, 0001_initial]
- [release_util, 0002_second]
- [release_util, 0003_third]
- [release_util, 0004_fourth]
initial_states:
- [release_util, zero]
"""
Expand Down
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# make upgrade
#
asgiref==3.5.0
asgiref==3.7.2
# via django
django==3.2.12
# via
Expand Down
2 changes: 1 addition & 1 deletion requirements/quality.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# make upgrade
#
asgiref==3.5.0
asgiref==3.7.2
# via
# -r requirements/test.txt
# django
Expand Down
2 changes: 1 addition & 1 deletion requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# make upgrade
#
asgiref==3.5.0
asgiref==3.7.2
# via
# -r requirements/base.txt
# django
Expand Down
2 changes: 1 addition & 1 deletion settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
'release_util': 'release_util.tests.migrations.test_migrations'
}

MIDDLEWARE_CLASSES = (
MIDDLEWARE = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware'
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,6 @@ def get_version(*file_paths):
'Programming Language :: Python :: 3.8',
'Framework :: Django',
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.2',
],
)
15 changes: 8 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py38-django{32}
envlist = py38-django{32, 42}

[pycodestyle]
exclude = .git,.tox,migrations
Expand All @@ -14,22 +14,23 @@ DJANGO_SETTINGS_MODULE = settings
norecursedirs = .* docs requirements

[testenv]
setenv =
setenv =
PYTHONPATH = {toxinidir}
deps =
deps =
django32: Django>=3.2,<4.0
django42: Django>=4.2,<4.3
-rrequirements/test.txt
-rrequirements/scripts.txt
commands =
commands =
pytest {posargs}

[testenv:quality]
whitelist_externals =
allowlist_externals =
make
rm
deps =
deps =
-r{toxinidir}/requirements/quality.txt
commands =
commands =
pycodestyle release_util manage.py setup.py
pydocstyle release_util manage.py setup.py
isort --check-only --diff release_util manage.py setup.py settings.py
Expand Down

0 comments on commit c6d58ec

Please sign in to comment.