summaryrefslogtreecommitdiff
path: root/tests/inspectdb
diff options
context:
space:
mode:
authorNick Pope <nick.pope@flightdataservices.com>2018-09-12 01:36:15 +0100
committerTim Graham <timograham@gmail.com>2018-10-02 14:01:24 -0400
commit45ef3df7d07489ee0b76479cc799faa92e443a69 (patch)
tree1b91f9ef203a2175ae644c6c7c319b3d4f866291 /tests/inspectdb
parent31edb106b5ce3aa125121b748782743f19338307 (diff)
downloaddjango-45ef3df7d07489ee0b76479cc799faa92e443a69.tar.gz
Fixed #29719 -- Added introspection of foreign tables for PostgreSQL.
Thanks infinite-l00p for the initial patch.
Diffstat (limited to 'tests/inspectdb')
-rw-r--r--tests/inspectdb/tests.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/inspectdb/tests.py b/tests/inspectdb/tests.py
index e994b2cb74..83c49eb7e3 100644
--- a/tests/inspectdb/tests.py
+++ b/tests/inspectdb/tests.py
@@ -309,3 +309,32 @@ class InspectDBTransactionalTests(TransactionTestCase):
finally:
with connection.cursor() as cursor:
cursor.execute('DROP VIEW inspectdb_people_view')
+
+ @skipUnless(connection.vendor == 'postgresql', 'PostgreSQL specific SQL')
+ def test_foreign_data_wrapper(self):
+ with connection.cursor() as cursor:
+ cursor.execute('CREATE EXTENSION IF NOT EXISTS file_fdw')
+ cursor.execute('CREATE SERVER inspectdb_server FOREIGN DATA WRAPPER file_fdw')
+ cursor.execute('''\
+ CREATE FOREIGN TABLE inspectdb_iris_foreign_table (
+ petal_length real,
+ petal_width real,
+ sepal_length real,
+ sepal_width real
+ ) SERVER inspectdb_server OPTIONS (
+ filename '/dev/null'
+ )
+ ''')
+ out = StringIO()
+ foreign_table_model = 'class InspectdbIrisForeignTable(models.Model):'
+ foreign_table_managed = 'managed = False'
+ try:
+ call_command('inspectdb', stdout=out)
+ output = out.getvalue()
+ self.assertIn(foreign_table_model, output)
+ self.assertIn(foreign_table_managed, output)
+ finally:
+ with connection.cursor() as cursor:
+ cursor.execute('DROP FOREIGN TABLE IF EXISTS inspectdb_iris_foreign_table')
+ cursor.execute('DROP SERVER IF EXISTS inspectdb_server')
+ cursor.execute('DROP EXTENSION IF EXISTS file_fdw')