Skip to content

Commit 39d29c5

Browse files
fsbraunpre-commit-ci[bot]sourcery-ai[bot]
authored
fix: Adds missing migrations and test for missing migrations (#303)
* fix: Adds missing migrations and test for missing migrations * ci: auto fixes from pre-commit hooks for more information, see https://pre-commit.ci * Update tests/test_migrations.py Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> * fix: Add verbosity to migration test * fix: Remove choices from AliasContent language field --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
1 parent 8a3b91d commit 39d29c5

File tree

4 files changed

+60
-5
lines changed

4 files changed

+60
-5
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ jobs:
1515
strategy:
1616
matrix:
1717
python-version:
18-
- '3.10'
1918
- '3.11'
2019
- '3.12'
2120
- '3.13'
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Generated by Django 5.2.7 on 2025-10-08 07:54
2+
3+
import django.db.models.deletion
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
dependencies = [
9+
("djangocms_alias", "0006_alter_alias_id_alter_aliascontent_id_and_more"),
10+
]
11+
12+
operations = [
13+
migrations.AlterModelOptions(
14+
name="category",
15+
options={
16+
"ordering": ["translations__name"],
17+
"verbose_name": "category",
18+
"verbose_name_plural": "categories",
19+
},
20+
),
21+
migrations.AlterField(
22+
model_name="aliasplugin",
23+
name="alias",
24+
field=models.ForeignKey(
25+
on_delete=django.db.models.deletion.PROTECT,
26+
related_name="cms_plugins",
27+
to="djangocms_alias.alias",
28+
verbose_name="alias",
29+
),
30+
),
31+
]

djangocms_alias/models.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,6 @@ class Meta:
278278
verbose_name = _("alias content")
279279
verbose_name_plural = _("alias contents")
280280

281-
def __init__(self, *args, **kwargs):
282-
super().__init__(*args, **kwargs)
283-
self._meta.get_field("language").choices = settings.LANGUAGES
284-
285281
def __str__(self):
286282
return f"{self.name} ({self.language})"
287283

tests/test_migrations.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from io import StringIO
2+
3+
from django.core.management import call_command
4+
from django.test import TestCase, override_settings
5+
6+
7+
class MigrationTestCase(TestCase):
8+
# Override MIGRATION_MODULES to {} to ensure all migrations are detected and not skipped for any app.
9+
@override_settings(MIGRATION_MODULES={})
10+
def test_for_missing_migrations(self):
11+
output = StringIO()
12+
options = {
13+
"interactive": False,
14+
"dry_run": True,
15+
"stdout": output,
16+
"check_changes": True,
17+
"verbosity": 3,
18+
}
19+
20+
try:
21+
call_command("makemigrations", "djangocms_alias", **options)
22+
except SystemExit as e:
23+
status_code = str(e)
24+
else:
25+
# the "no changes" exit code is 0
26+
status_code = "0"
27+
28+
if status_code == "1":
29+
self.fail(f"There are missing migrations:\n {output.getvalue()}")

0 commit comments

Comments
 (0)