def test_set_schema(completer): text = ('SET SCHEMA ') result = get_result(completer, text) assert completions_to_set(result) == completions_to_set([ schema(u"'blog'"), schema(u"'Custom'"), schema(u"'custom'"), schema(u"'public'")])
def test_set_schema(completer): text = ('SET SCHEMA ') result = result_set(completer, text) assert result == set([ schema(u"'blog'"), schema(u"'Custom'"), schema(u"'custom'"), schema(u"'public'")])
def test_set_schema(completer): text = "SET SCHEMA " result = get_result(completer, text) assert completions_to_set(result) == completions_to_set([ schema("'blog'"), schema("'Custom'"), schema("'custom'"), schema("'public'") ])
def test_table_casing(completer_with_casing, complete_event, text): result = completer_with_casing.get_completions( Document(text=text), complete_event) assert set(result) == set([ schema('public'), schema('CUSTOM'), schema('"Custom"'), table('users'), table('Orders'), table('"select"'), function('Func1()'), function('func2()')])
def test_aliases_with_casing(completer_aliases_casing, complete_event, text): result = completer_aliases_casing.get_completions( Document(text=text), complete_event) assert set(result) == set([ schema('public'), schema('CUSTOM'), schema('"Custom"'), table('users u'), table('Orders O' if text == 'SELECT * FROM ' else 'Orders O2'), table('"select" s'), function('Func1() F'), function('func2() f')])
def test_table_casing(completer_with_casing, complete_event, text): result = completer_with_casing.get_completions(Document(text=text), complete_event) assert set(result) == set([ schema('public'), schema('CUSTOM'), schema('"Custom"'), table('users'), table('Orders'), table('"select"'), function('Func1()'), function('func2()') ])
def test_aliases_with_casing(completer_aliases_casing, complete_event, text): result = completer_aliases_casing.get_completions(Document(text=text), complete_event) assert set(result) == set([ schema('public'), schema('CUSTOM'), schema('"Custom"'), table('users u'), table('Orders O' if text == 'SELECT * FROM ' else 'Orders O2'), table('"select" s'), function('Func1() F'), function('func2() f') ])
def test_cased_joins(completer, text): result = result_set(completer, text) assert result == set([schema('PUBLIC')] + cased_rels + [ join('"Users" ON "Users".UserID = Users.ID'), join('Users Users2 ON Users2.ID = Users.PARENTID'), join('Users Users2 ON Users2.PARENTID = Users.ID'), ])
def test_cased_joins(completer, text): result = get_result(completer, text) assert completions_to_set(result) == completions_to_set([schema('PUBLIC')] + cased_rels + [ join('"Users" ON "Users".UserID = Users.ID'), join('Users Users2 ON Users2.ID = Users.PARENTID'), join('Users Users2 ON Users2.PARENTID = Users.ID'), ])
def test_cased_joins(cased_completer, complete_event, text): result = set(cased_completer.get_completions( Document(text=text), complete_event)) assert set(result) == set([schema('PUBLIC')] + cased_rels + [ join('"Users" ON "Users".UserID = Users.ID'), join('Users Users2 ON Users2.ID = Users.PARENTID'), join('Users Users2 ON Users2.PARENTID = Users.ID'), ])
def test_cased_joins(cased_completer, complete_event, text): result = set( cased_completer.get_completions(Document(text=text), complete_event)) assert set(result) == set([schema('PUBLIC')] + cased_rels + [ join('"Users" ON "Users".UserID = Users.ID'), join('Users Users2 ON Users2.ID = Users.PARENTID'), join('Users Users2 ON Users2.PARENTID = Users.ID'), ])
def test_duplicate_aliases_with_casing(completer, text): result = result_set(completer, text) assert result == set([ schema('PUBLIC'), table('Orders O2'), table('Users U'), table('"Users" U'), table('"select" s'), view('User_Emails UE'), function('_custom_fun() cf'), function('Custom_Fun() CF'), function('Custom_Func1() CF'), function('custom_func2() cf'), function('set_returning_func() srf')])
def test_duplicate_aliases_with_casing(cased_aliased_completer, complete_event, text): result = cased_aliased_completer.get_completions( Document(text=text), complete_event) assert set(result) == set([ schema('PUBLIC'), table('Orders O2'), table('Users U'), table('"Users" U'), table('"select" s'), view('User_Emails UE'), function('_custom_fun() cf'), function('Custom_Fun() CF'), function('Custom_Func1() CF'), function('custom_func2() cf'), function('set_returning_func() srf')])
def test_duplicate_aliases_with_casing(completer, text): result = get_result(completer, text) assert completions_to_set(result) == completions_to_set([ schema("PUBLIC"), table("Orders O2"), table("Users U"), table('"Users" U'), table('"select" s'), view("User_Emails UE"), view("Functions F"), function("_custom_fun() cf"), function("Custom_Fun() CF"), function("Custom_Func1() CF"), function("custom_func2() cf"), function( "set_returning_func(x := , y := ) srf", display="set_returning_func(x, y) srf", ), ])
def test_duplicate_aliases_with_casing(completer, text): result = get_result(completer, text) assert completions_to_set(result) == completions_to_set([ schema('PUBLIC'), table('Orders O2'), table('Users U'), table('"Users" U'), table('"select" s'), view('User_Emails UE'), view('Functions F'), function('_custom_fun() cf'), function('Custom_Fun() CF'), function('Custom_Func1() CF'), function('custom_func2() cf'), function( 'set_returning_func(x := , y := ) srf', display='set_returning_func(x, y) srf' ), ])
def test_list_functions_for_special(completer): result = result_set(completer, r'\df ') assert result == set( [schema('PUBLIC')] + [function(f) for f in cased_func_names] )
def test_list_functions_for_special(completer): result = get_result(completer, r'\df ') assert completions_to_set(result) == completions_to_set( [schema('PUBLIC')] + [function(f) for f in cased_func_names] )
def test_table_casing(cased_completer, complete_event, text): result = cased_completer.get_completions(Document(text=text), complete_event) assert set(result) == set([schema('PUBLIC')] + cased_rels)
def test_aliases_with_casing(completer, text): result = result_set(completer, text) assert result == set([schema('PUBLIC')] + cased_aliased_rels)
def test_aliases_with_casing(completer, text): result = get_result(completer, text) assert completions_to_set(result) == completions_to_set( [schema("PUBLIC")] + cased_aliased_rels)
def test_list_functions_for_special(completer): result = result_set(completer, r'\df ') assert result == set([schema('PUBLIC')] + [function(f) for f in cased_func_names])
def test_table_casing(completer, text): result = result_set(completer, text) assert result == set([schema('PUBLIC')] + cased_rels)
def test_set_schema(completer): text = ('SET SCHEMA ') result = result_set(completer, text) expected = set([schema(u"'public'")]) assert result == expected
("blog", "entries", "entryid", "blog", "entacclog", "entryid"), ("blog", "entries", "entryid", "blog", "entrytags", "entryid"), ("blog", "tags", "tagid", "blog", "entrytags", "tagid"), ], }, "defaults": { "public": { ("orders", "id"): "nextval('orders_id_seq'::regclass)", ("orders", "datestamp"): "now()", ("orders", "status"): "'PENDING'::text", } }, } testdata = MetaData(metadata) cased_schemas = [schema(x) for x in ("public", "blog", "CUSTOM", '"Custom"')] casing = ( "SELECT", "Orders", "User_Emails", "CUSTOM", "Func1", "Entries", "Tags", "EntryTags", "EntAccLog", "EntryID", "EntryTitle", "EntryText", ) completers = testdata.get_completers(casing)
('blog', 'entries', 'entryid', 'blog', 'entacclog', 'entryid'), ('blog', 'entries', 'entryid', 'blog', 'entrytags', 'entryid'), ('blog', 'tags', 'tagid', 'blog', 'entrytags', 'tagid'), ], }, 'defaults': { 'public': { ('orders', 'id'): "nextval('orders_id_seq'::regclass)", ('orders', 'datestamp'): "now()", ('orders', 'status'): "'PENDING'::text", } }, } testdata = MetaData(metadata) cased_schemas = [schema(x) for x in ('public', 'blog', 'CUSTOM', '"Custom"')] casing = ('SELECT', 'Orders', 'User_Emails', 'CUSTOM', 'Func1', 'Entries', 'Tags', 'EntryTags', 'EntAccLog', 'EntryID', 'EntryTitle', 'EntryText') 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) : result = get_result(completer, 'SELECT FROM ' + table, len('SELECT ')) assert completions_to_set(result) == completions_to_set( testdata.columns_functions_and_keywords('users')) @parametrize('completer', completers(filtr=True, casing=False, qualify=no_qual))
def test_set_schema(completer): text = ('SET SCHEMA ') result = get_result(completer, text) expected = completions_to_set([schema(u"'public'")]) assert completions_to_set(result) == expected
def test_table_casing(cased_completer, complete_event, text): result = cased_completer.get_completions( Document(text=text), complete_event) assert set(result) == set([schema('PUBLIC')] + cased_rels)
def test_table_casing(completer, text): result = get_result(completer, text) assert completions_to_set(result) == completions_to_set( [schema('PUBLIC')] + cased_rels)
'custom': ['typ3', 'typ4'], }, 'foreignkeys': { 'custom': [ ('public', 'users', 'id', 'custom', 'shipments', 'user_id') ], 'blog': [ ('blog', 'entries', 'entryid', 'blog', 'entacclog', 'entryid'), ('blog', 'entries', 'entryid', 'blog', 'entrytags', 'entryid'), ('blog', 'tags', 'tagid', 'blog', 'entrytags', 'tagid'), ], }, } testdata = MetaData(metadata) cased_schemas = [schema(x) for x in ('public', 'blog', 'CUSTOM', '"Custom"')] @pytest.fixture def completer(): return testdata.completer casing = ('SELECT', 'Orders', 'User_Emails', 'CUSTOM', 'Func1', 'Entries', 'Tags', 'EntryTags', 'EntAccLog', 'EntryID', 'EntryTitle', 'EntryText') @pytest.fixture def completer_with_casing(): return testdata.get_completer(casing=casing) @pytest.fixture def completer_with_aliases():