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/__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 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..4630257 --- /dev/null +++ b/release_util/tests/migrations/test_migrations/0004_fourth.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), + ), + ] 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