summaryrefslogtreecommitdiff
path: root/tests/postgres_tests
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2017-09-09 14:39:09 +0200
committerClaude Paroz <claude@2xlibre.net>2017-09-09 18:26:29 +0200
commit0cbb6ac00770d201b8f30a404d516b97fe41485d (patch)
tree59d7c55f7808e1ba186f53fdf8008a5b7797dab2 /tests/postgres_tests
parentffbee67f8e17e1cfffcaa0116c170141a7363dda (diff)
Refs #24928 -- Added introspection support for PostgreSQL JSONField
Thanks Adam Johnson and Tim Graham for the reviews.
Diffstat (limited to 'tests/postgres_tests')
-rw-r--r--tests/postgres_tests/test_introspection.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/postgres_tests/test_introspection.py b/tests/postgres_tests/test_introspection.py
new file mode 100644
index 0000000000..1058a1656b
--- /dev/null
+++ b/tests/postgres_tests/test_introspection.py
@@ -0,0 +1,26 @@
+from io import StringIO
+
+from django.core.management import call_command
+from django.test.utils import modify_settings
+
+from . import PostgreSQLTestCase
+
+
+@modify_settings(INSTALLED_APPS={'append': 'django.contrib.postgres'})
+class InspectDBTests(PostgreSQLTestCase):
+ def assertFieldsInModel(self, model, field_outputs):
+ out = StringIO()
+ call_command(
+ 'inspectdb',
+ table_name_filter=lambda tn: tn.startswith(model),
+ stdout=out,
+ )
+ output = out.getvalue()
+ for field_output in field_outputs:
+ self.assertIn(field_output, output)
+
+ def test_json_field(self):
+ self.assertFieldsInModel(
+ 'postgres_tests_jsonmodel',
+ ['field = django.contrib.postgresql.fields.JSONField(blank=True, null=True)'],
+ )