summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDarik Gamble <darik.gamble@gmail.com>2015-03-03 08:28:43 -0500
committerDarik Gamble <darik.gamble@gmail.com>2015-04-05 16:38:02 -0400
commitd437f0cabf7fe04ea6ebd48d8ea6fb2194a6e949 (patch)
tree6c6e8b0b3242f5d2e86e8bc715599334aa565d55 /tests
parent9e812e5bf80f461e6fe5ac71a49487b50eeba153 (diff)
pgexecute supports returning view metadata
generalize tables() to _relations(relkind_filter), and add convenience methods tables() and views() which simply call _relations() with the appropriate relkind_filter value similarly, generatize columns() to _columns(relkind_filter), and add convenience methods table_columns() and view_columns()
Diffstat (limited to 'tests')
-rw-r--r--tests/test_pgexecute.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/tests/test_pgexecute.py b/tests/test_pgexecute.py
index a89c714a..66148848 100644
--- a/tests/test_pgexecute.py
+++ b/tests/test_pgexecute.py
@@ -30,22 +30,32 @@ def test_bools_are_treated_as_strings(executor):
SELECT 1""")
@dbtest
-def test_schemata_table_and_columns_query(executor):
+def test_schemata_table_views_and_columns_query(executor):
run(executor, "create table a(x text, y text)")
run(executor, "create table b(z text)")
+ run(executor, "create view d as select 1 as e")
run(executor, "create schema schema1")
run(executor, "create table schema1.c (w text)")
run(executor, "create schema schema2")
+ # schemata
assert executor.schemata() == ['public', 'schema1', 'schema2']
- assert executor.tables() == [
+ assert executor.search_path() == ['public']
+
+ # tables
+ assert list(executor.tables()) == [
('public', 'a'), ('public', 'b'), ('schema1', 'c')]
- assert executor.columns() == [
+ assert list(executor.table_columns()) == [
('public', 'a', 'x'), ('public', 'a', 'y'),
('public', 'b', 'z'), ('schema1', 'c', 'w')]
- assert executor.search_path() == ['public']
+ # views
+ assert list(executor.views()) == [
+ ('public', 'd')]
+
+ assert list(executor.view_columns()) == [
+ ('public', 'd', 'e')]
@dbtest
def test_functions_query(executor):