diff options
author | Joakim Koljonen <koljonen@outlook.com> | 2017-03-06 01:59:04 +0100 |
---|---|---|
committer | Joakim Koljonen <koljonen@outlook.com> | 2017-03-15 02:58:02 +0100 |
commit | 6188c86201484fcbf715ad08dc795447293122e2 (patch) | |
tree | 8d301a703315ad8dbd92c6f0e3a436f6f7abccfb /tests/test_smart_completion_multiple_schemata.py | |
parent | 17ff3bb937515e64eecd7d0d72082eb89201b611 (diff) |
Deduplicate tests: Add some helper functions to metadata.py
Diffstat (limited to 'tests/test_smart_completion_multiple_schemata.py')
-rw-r--r-- | tests/test_smart_completion_multiple_schemata.py | 72 |
1 files changed, 25 insertions, 47 deletions
diff --git a/tests/test_smart_completion_multiple_schemata.py b/tests/test_smart_completion_multiple_schemata.py index 9bb92bf8..53c99a17 100644 --- a/tests/test_smart_completion_multiple_schemata.py +++ b/tests/test_smart_completion_multiple_schemata.py @@ -69,42 +69,29 @@ completers = testdata.get_completers(casing) @parametrize('completer', completers(filtr=True, casing=False, qualify=no_qual)) -@parametrize('table', [ - 'users', - '"users"', - ]) -def test_suggested_column_names_from_shadowed_visible_table(completer, table): +@parametrize('table', ['users', '"users"']) +def test_suggested_column_names_from_shadowed_visible_table(completer, table) : result = result_set(completer, 'SELECT FROM ' + table, len('SELECT ')) - assert result == set(testdata.columns('users') + - testdata.functions() + - list(testdata.builtin_functions() + - testdata.keywords()) - ) + assert result == set(testdata.columns_functions_and_keywords('users')) @parametrize('completer', completers(filtr=True, casing=False, qualify=no_qual)) @parametrize('text', [ 'SELECT from custom.users', 'WITH users as (SELECT 1 AS foo) SELECT from custom.users', - ]) +]) def test_suggested_column_names_from_qualified_shadowed_table(completer, text): result = result_set(completer, text, position = text.find(' ') + 1) - assert result == set(testdata.columns('users', 'custom') + - testdata.functions() + - list(testdata.builtin_functions() + - testdata.keywords()) - ) + assert result == set(testdata.columns_functions_and_keywords( + 'users', 'custom' + )) @parametrize('completer', completers(filtr=True, casing=False, qualify=no_qual)) -@parametrize('text', [ - 'WITH users as (SELECT 1 AS foo) SELECT from users', - ]) +@parametrize('text', ['WITH users as (SELECT 1 AS foo) SELECT from users',]) def test_suggested_column_names_from_cte(completer, text): result = result_set(completer, text, text.find(' ') + 1) - assert result == set([column('foo')] + testdata.functions() + - list(testdata.builtin_functions() + testdata.keywords()) - ) + assert result == set([column('foo')] + testdata.functions_and_keywords()) @parametrize('completer', completers(casing=False)) @@ -132,9 +119,10 @@ def test_suggested_join_conditions(completer, text): ), ('users', '"users"', 'Users'))) def test_suggested_joins(completer, query, tbl): result = result_set(completer, query.format(tbl)) - assert result == set(testdata.schemas() + testdata.tables() + [ - join('custom.shipments ON shipments.user_id = {0}.id'.format(tbl)), - ] + testdata.functions()) + assert result == set( + testdata.schemas_and_from_clause_items() + + [join('custom.shipments ON shipments.user_id = {0}.id'.format(tbl))] + ) @parametrize('completer', completers(filtr=True, casing=False, qualify=no_qual)) @@ -142,10 +130,9 @@ def test_suggested_column_names_from_schema_qualifed_table(completer): result = result_set( completer, 'SELECT from custom.products', len('SELECT ') ) - assert result == set( - testdata.columns('products', 'custom') + testdata.functions() + - list(testdata.builtin_functions() + testdata.keywords()) - ) + assert result == set(testdata.columns_functions_and_keywords( + 'products', 'custom' + )) @parametrize('completer', completers(filtr=True, casing=False, qualify=no_qual)) @@ -173,8 +160,7 @@ def test_suggested_table_names_with_schema_dot( start_position = 0 result = result_set(completer, text) - assert result == set(testdata.tables('custom', start_position) - + testdata.functions('custom', start_position)) + assert result == set(testdata.from_clause_items('custom', start_position)) @parametrize('completer', completers(casing=False, alias=False)) @@ -192,8 +178,7 @@ def test_suggested_table_names_with_schema_dot2( start_position = 0 result = result_set(completer, text) - assert result == set(testdata.functions('Custom', start_position) + - testdata.tables('Custom', start_position)) + assert result == set(testdata.from_clause_items('Custom', start_position)) @parametrize('completer', completers(filtr=True, casing=False)) @@ -209,11 +194,9 @@ def test_suggested_multiple_column_names(completer): result = result_set( completer, 'SELECT id, from custom.products', len('SELECT id, ') ) - assert result == set(testdata.columns('products', 'custom') + - testdata.functions() + - list(testdata.builtin_functions() + - testdata.keywords()) - ) + assert result == set(testdata.columns_functions_and_keywords( + 'products', 'custom' + )) @parametrize('completer', completers(filtr=True, casing=False)) @@ -246,17 +229,14 @@ def test_suggestions_after_on(completer, text): def test_suggested_aliases_after_on_right_side(completer): text = 'SELECT x.id, y.product_name FROM custom.products x JOIN custom.products y ON x.id = ' result = result_set(completer, text) - assert result == set([ - alias('x'), - alias('y')]) + assert result == set([alias('x'), alias('y')]) @parametrize('completer', completers(filtr=True, casing=False, alias=False)) def test_table_names_after_from(completer): text = 'SELECT * FROM ' result = result_set(completer, text) - assert result == set(testdata.schemas() + testdata.tables() - + testdata.functions()) + assert result == set(testdata.schemas_and_from_clause_items()) @parametrize('completer', completers(filtr=True, casing=False)) @@ -277,8 +257,7 @@ def test_schema_qualified_function_name(completer): ]) def test_schema_qualified_type_name(completer, text): result = result_set(completer, text) - assert result == set(testdata.datatypes('custom') - + testdata.tables('custom')) + assert result == set(testdata.types('custom')) @parametrize('completer', completers(filtr=True, casing=False)) @@ -431,8 +410,7 @@ texts = ['SELECT * FROM ', 'SELECT * FROM public.Orders O CROSS JOIN '] @parametrize('text', texts) def test_schema_or_visible_table_completion(completer, text): result = result_set(completer, text) - assert result == set(testdata.schemas() - + testdata.views() + testdata.tables() + testdata.functions()) + assert result == set(testdata.schemas_and_from_clause_items()) @parametrize('completer', completers(alias=True, casing=False, filtr=True)) |