forked from kiwitcms/Kiwi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs kiwitcms#1696. Add middleware to warn for unapplied migrations
- Loading branch information
Showing
8 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import os | ||
import unittest | ||
from django import test | ||
from django.conf import settings | ||
from django.apps import apps | ||
from django.contrib.messages import get_messages | ||
|
||
|
||
@unittest.skipUnless( | ||
os.getenv('TEST_CHECK_UNAPPLIED_MIGRATIONS_MIDDLEWARE'), | ||
'CheckUnappliedMigrationsMiddleware testing not enabled') | ||
class TestCheckUnappliedMigrationsMiddleware(test.TestCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
settings.INSTALLED_APPS.append("tcms.core.tests.test_migrations_app") | ||
apps.set_installed_apps(settings.INSTALLED_APPS) | ||
|
||
@test.override_settings(MIGRATION_MODULES={ | ||
"migrations": "tcms.core.tests.test_migrations_app.migrations"}) | ||
def test_unapplied_migrations(self): | ||
unapplied_migration_message = """You have 1 unapplied migration(s).\ | ||
See <a href="https://kiwitcms.readthedocs.io/en/latest/installing_docker.html\ | ||
#initial-configuration-of-running-container">documentation</a>""" | ||
response = self.client.get('/', follow=True) | ||
self.assertContains(response, unapplied_migration_message) |
Empty file.
15 changes: 15 additions & 0 deletions
15
tcms/core/tests/test_migrations_app/migrations/0001_initial.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
operations = [ | ||
|
||
migrations.CreateModel( | ||
"TestPerson", | ||
[ | ||
("id", models.AutoField(primary_key=True)), | ||
("name", models.CharField(max_length=10)), | ||
], | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.db import models | ||
|
||
|
||
class TestPerson(models.Model): | ||
name = models.CharField(max_length=10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters