summaryrefslogtreecommitdiff
path: root/tests/postgres_tests
diff options
context:
space:
mode:
authorDavid Wobrock <david.wobrock@gmail.com>2022-07-02 19:55:37 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-07-08 07:05:55 +0200
commit41019e48bbf082c985e6ba3bad34d118b903bff1 (patch)
tree63e08889847484c233e690c81375f7a4e73eec18 /tests/postgres_tests
parent57793b47657ace966ce8ce96d801ac0d85e5efc6 (diff)
Refs #27236 -- Added generic mechanism to handle the deprecation of migration operations.
Diffstat (limited to 'tests/postgres_tests')
-rw-r--r--tests/postgres_tests/migrations/0001_setup_extensions.py33
1 files changed, 22 insertions, 11 deletions
diff --git a/tests/postgres_tests/migrations/0001_setup_extensions.py b/tests/postgres_tests/migrations/0001_setup_extensions.py
index 090abf9649..3edeff7b82 100644
--- a/tests/postgres_tests/migrations/0001_setup_extensions.py
+++ b/tests/postgres_tests/migrations/0001_setup_extensions.py
@@ -1,6 +1,17 @@
-from unittest import mock
-
from django.db import connection, migrations
+from django.db.migrations.operations.base import Operation
+
+
+class DummyOperation(Operation):
+ def state_forwards(self, app_label, state):
+ pass
+
+ def database_forwards(self, app_label, schema_editor, from_state, to_state):
+ pass
+
+ def database_backwards(self, app_label, schema_editor, from_state, to_state):
+ pass
+
try:
from django.contrib.postgres.operations import (
@@ -15,14 +26,14 @@ try:
UnaccentExtension,
)
except ImportError:
- BloomExtension = mock.Mock()
- BtreeGinExtension = mock.Mock()
- BtreeGistExtension = mock.Mock()
- CITextExtension = mock.Mock()
- CreateExtension = mock.Mock()
- HStoreExtension = mock.Mock()
- TrigramExtension = mock.Mock()
- UnaccentExtension = mock.Mock()
+ BloomExtension = DummyOperation
+ BtreeGinExtension = DummyOperation
+ BtreeGistExtension = DummyOperation
+ CITextExtension = DummyOperation
+ CreateExtension = DummyOperation
+ HStoreExtension = DummyOperation
+ TrigramExtension = DummyOperation
+ UnaccentExtension = DummyOperation
needs_crypto_extension = False
else:
needs_crypto_extension = (
@@ -41,7 +52,7 @@ class Migration(migrations.Migration):
# dash in its name.
CreateExtension("uuid-ossp"),
# CryptoExtension is required for RandomUUID() on PostgreSQL < 13.
- CryptoExtension() if needs_crypto_extension else mock.Mock(),
+ CryptoExtension() if needs_crypto_extension else DummyOperation(),
HStoreExtension(),
TrigramExtension(),
UnaccentExtension(),