From 1a7a4aac44360fee916812605e9e6b9187803b24 Mon Sep 17 00:00:00 2001 From: zubairshakoorarbisoft Date: Mon, 17 Jul 2023 17:03:28 +0500 Subject: [PATCH 1/6] feat: Added support for Django 4.2 --- .github/workflows/ci.yml | 3 +- .../migrations/test_migrations/0004_fourth.py | 25 ++++++++++ .../test_app/test_app/settings.py | 1 - release_util/tests/test_migration_commands.py | 50 +++++++++++++++++++ requirements/base.txt | 2 +- requirements/quality.txt | 2 +- requirements/test.txt | 2 +- settings.py | 2 +- setup.py | 1 + tox.ini | 15 +++--- 10 files changed, 90 insertions(+), 13 deletions(-) create mode 100644 release_util/tests/migrations/test_migrations/0004_fourth.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 591fe61..1914492 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -34,3 +34,4 @@ jobs: env: TOXENV: ${{ matrix.toxenv }} run: tox + \ No newline at end of file diff --git a/release_util/tests/migrations/test_migrations/0004_fourth.py b/release_util/tests/migrations/test_migrations/0004_fourth.py new file mode 100644 index 0000000..edbad11 --- /dev/null +++ b/release_util/tests/migrations/test_migrations/0004_fourth.py @@ -0,0 +1,25 @@ +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), + ), + ] diff --git a/release_util/tests/test_check_reserved_keywords/test_app/test_app/settings.py b/release_util/tests/test_check_reserved_keywords/test_app/test_app/settings.py index 575ac90..5aaa0a3 100644 --- a/release_util/tests/test_check_reserved_keywords/test_app/test_app/settings.py +++ b/release_util/tests/test_check_reserved_keywords/test_app/test_app/settings.py @@ -103,7 +103,6 @@ USE_I18N = True -USE_L10N = True USE_TZ = True diff --git a/release_util/tests/test_migration_commands.py b/release_util/tests/test_migration_commands.py index 46f8664..234076c 100644 --- a/release_util/tests/test_migration_commands.py +++ b/release_util/tests/test_migration_commands.py @@ -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 @@ -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 @@ -220,6 +222,7 @@ 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 @@ -227,6 +230,25 @@ def test_showmigrations_list(self): 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), @@ -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] """ @@ -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': [], @@ -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] """ @@ -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, @@ -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): @@ -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] """ diff --git a/requirements/base.txt b/requirements/base.txt index b5da495..e45f7c9 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -4,7 +4,7 @@ # # make upgrade # -asgiref==3.5.0 +asgiref==3.7.2 # via django django==3.2.12 # via diff --git a/requirements/quality.txt b/requirements/quality.txt index 9be6f3a..19c4f92 100644 --- a/requirements/quality.txt +++ b/requirements/quality.txt @@ -4,7 +4,7 @@ # # make upgrade # -asgiref==3.5.0 +asgiref==3.7.2 # via # -r requirements/test.txt # django diff --git a/requirements/test.txt b/requirements/test.txt index eeaa066..9c2efaa 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -4,7 +4,7 @@ # # make upgrade # -asgiref==3.5.0 +asgiref==3.7.2 # via # -r requirements/base.txt # django diff --git a/settings.py b/settings.py index cf329a2..998152b 100644 --- a/settings.py +++ b/settings.py @@ -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' diff --git a/setup.py b/setup.py index 36d9099..afb6c7f 100644 --- a/setup.py +++ b/setup.py @@ -76,5 +76,6 @@ def get_version(*file_paths): 'Programming Language :: Python :: 3.8', 'Framework :: Django', 'Framework :: Django :: 3.2', + 'Framework :: Django :: 4.2', ], ) diff --git a/tox.ini b/tox.ini index 2cb0f12..1201fc0 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py38-django{32} +envlist = py38-django{32, 42} [pycodestyle] exclude = .git,.tox,migrations @@ -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 From 98bfdc94b1d12512750232a0fe1d45348d9f295f Mon Sep 17 00:00:00 2001 From: zubairshakoorarbisoft Date: Tue, 18 Jul 2023 16:21:50 +0500 Subject: [PATCH 2/6] fix: requested changed by awais added --- .../migrations/test_migrations/0004_fourth.py | 25 ------------------- .../test_app/test_app/settings.py | 1 + release_util/tests/test_migration_commands.py | 19 -------------- 3 files changed, 1 insertion(+), 44 deletions(-) delete mode 100644 release_util/tests/migrations/test_migrations/0004_fourth.py diff --git a/release_util/tests/migrations/test_migrations/0004_fourth.py b/release_util/tests/migrations/test_migrations/0004_fourth.py deleted file mode 100644 index edbad11..0000000 --- a/release_util/tests/migrations/test_migrations/0004_fourth.py +++ /dev/null @@ -1,25 +0,0 @@ -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), - ), - ] diff --git a/release_util/tests/test_check_reserved_keywords/test_app/test_app/settings.py b/release_util/tests/test_check_reserved_keywords/test_app/test_app/settings.py index 5aaa0a3..575ac90 100644 --- a/release_util/tests/test_check_reserved_keywords/test_app/test_app/settings.py +++ b/release_util/tests/test_check_reserved_keywords/test_app/test_app/settings.py @@ -103,6 +103,7 @@ USE_I18N = True +USE_L10N = True USE_TZ = True diff --git a/release_util/tests/test_migration_commands.py b/release_util/tests/test_migration_commands.py index 234076c..26d219f 100644 --- a/release_util/tests/test_migration_commands.py +++ b/release_util/tests/test_migration_commands.py @@ -230,25 +230,6 @@ def test_showmigrations_list(self): 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), From 2a4b29e53e4147ca19a4bb516a6508afc8cc2237 Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Mon, 24 Jul 2023 16:39:08 +0500 Subject: [PATCH 3/6] chore: Adding missing migration. It's due to django40 https://docs.djangoproject.com/en/4.0/releases/4.0/#migrations-autodetector-changes --- ...hor_id_alter_book_id_alter_bookstore_id.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 release_util/tests/migrations/test_migrations/0004_alter_author_id_alter_book_id_alter_bookstore_id.py diff --git a/release_util/tests/migrations/test_migrations/0004_alter_author_id_alter_book_id_alter_bookstore_id.py b/release_util/tests/migrations/test_migrations/0004_alter_author_id_alter_book_id_alter_bookstore_id.py new file mode 100644 index 0000000..4630257 --- /dev/null +++ b/release_util/tests/migrations/test_migrations/0004_alter_author_id_alter_book_id_alter_bookstore_id.py @@ -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), + ), + ] From 7eca5253f901c1586ae6092b05f2a6da279d4363 Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Mon, 24 Jul 2023 16:57:19 +0500 Subject: [PATCH 4/6] chore: Adding missing migration. It's due to django40 https://docs.djangoproject.com/en/4.0/releases/4.0/#migrations-autodetector-changes --- ...thor_id_alter_book_id_alter_bookstore_id.py => 0004_fourth.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename release_util/tests/migrations/test_migrations/{0004_alter_author_id_alter_book_id_alter_bookstore_id.py => 0004_fourth.py} (100%) diff --git a/release_util/tests/migrations/test_migrations/0004_alter_author_id_alter_book_id_alter_bookstore_id.py b/release_util/tests/migrations/test_migrations/0004_fourth.py similarity index 100% rename from release_util/tests/migrations/test_migrations/0004_alter_author_id_alter_book_id_alter_bookstore_id.py rename to release_util/tests/migrations/test_migrations/0004_fourth.py From aca21919395a19874326a0d2cbc908a4d17b9e6b Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Mon, 24 Jul 2023 19:45:03 +0500 Subject: [PATCH 5/6] chore: Adding missing migration. It's due to django40 https://docs.djangoproject.com/en/4.0/releases/4.0/#migrations-autodetector-changes --- release_util/tests/test_migration_commands.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/release_util/tests/test_migration_commands.py b/release_util/tests/test_migration_commands.py index 26d219f..234076c 100644 --- a/release_util/tests/test_migration_commands.py +++ b/release_util/tests/test_migration_commands.py @@ -230,6 +230,25 @@ def test_showmigrations_list(self): 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), From a7e36e9b9d8bc969a06c6aefc0318b4218dd939d Mon Sep 17 00:00:00 2001 From: zubairshakoorarbisoft Date: Tue, 25 Jul 2023 13:42:14 +0500 Subject: [PATCH 6/6] fix: version bumped to 1.3.0 --- release_util/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release_util/__init__.py b/release_util/__init__.py index 10454e2..8b5115d 100644 --- a/release_util/__init__.py +++ b/release_util/__init__.py @@ -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