def test_duplicate_table_aliases(completer, text): result = result_set(completer, text) assert result == set(testdata.schemas() + [ 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 = 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'), 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_table_aliases(completer, text): result = get_result(completer, text) assert completions_to_set(result) == completions_to_set(testdata.schemas() + [ 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_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_table_aliases(completer, text): result = get_result(completer, text) assert completions_to_set(result) == completions_to_set( testdata.schemas() + [ 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_table_aliases(aliased_completer, complete_event, text): result = aliased_completer.get_completions( Document(text=text), complete_event) assert set(result) == set(testdata.schemas() + [ 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')])
cased_users2_col_names = ['UserID', 'UserName'] cased_func_names = [ 'Custom_Fun', '_custom_fun', 'Custom_Func1', 'custom_func2', 'set_returning_func' ] cased_tbls = ['Users', 'Orders'] cased_views = ['User_Emails', 'Functions'] casing = ( ['SELECT', 'PUBLIC'] + cased_func_names + cased_tbls + cased_views + cased_users_col_names + cased_users2_col_names ) # Lists for use in assertions cased_funcs = [ function(f) for f in ('Custom_Fun()', '_custom_fun()', 'Custom_Func1()', 'custom_func2()') ] + [function('set_returning_func(x := , y := )', display='set_returning_func(x, y)')] cased_tbls = [table(t) for t in (cased_tbls + ['"Users"', '"select"'])] cased_rels = [view(t) for t in cased_views] + cased_funcs + cased_tbls cased_users_cols = [column(c) for c in cased_users_col_names] aliased_rels = [ table(t) for t in ('users u', '"Users" U', 'orders o', '"select" s') ] + [view('user_emails ue'), view('functions f')] + [ function(f) for f in ( '_custom_fun() cf', 'custom_fun() cf', 'custom_func1() cf', 'custom_func2() cf' ) ] + [function( 'set_returning_func(x := , y := ) srf', display='set_returning_func(x, y) srf' )] cased_aliased_rels = [ table(t) for t in ('Users U', '"Users" U', 'Orders O', '"select" s') ] + [view('User_Emails UE'), view('Functions F')] + [
"set_returning_func", ] cased_tbls = ["Users", "Orders"] cased_views = ["User_Emails", "Functions"] casing = (["SELECT", "PUBLIC"] + cased_func_names + cased_tbls + cased_views + cased_users_col_names + cased_users2_col_names) # Lists for use in assertions cased_funcs = [ function(f) for f in ("Custom_Fun()", "_custom_fun()", "Custom_Func1()", "custom_func2()") ] + [ function("set_returning_func(x := , y := )", display="set_returning_func(x, y)") ] cased_tbls = [table(t) for t in (cased_tbls + ['"Users"', '"select"'])] cased_rels = [view(t) for t in cased_views] + cased_funcs + cased_tbls cased_users_cols = [column(c) for c in cased_users_col_names] aliased_rels = ( [table(t) for t in ("users u", '"Users" U', "orders o", '"select" s')] + [view("user_emails ue"), view("functions f")] + [ function(f) for f in ( "_custom_fun() cf", "custom_fun() cf", "custom_func1() cf", "custom_func2() cf", ) ] + [ function( "set_returning_func(x := , y := ) srf", display="set_returning_func(x, y) srf", )
metadata = dict((k, {'public': v}) for k, v in metadata.items()) testdata = MetaData(metadata) cased_users_cols = ['ID', 'PARENTID', 'Email', 'First_Name', 'last_name'] cased_users2_cols = ['UserID', 'UserName'] cased_funcs = ['Custom_Fun', '_custom_fun', 'Custom_Func1', 'custom_func2', 'set_returning_func'] cased_tbls = ['Users', 'Orders'] cased_views = ['User_Emails'] casing = (['SELECT', 'PUBLIC'] + cased_funcs + cased_tbls + cased_views + cased_users_cols + cased_users2_cols) # Lists for use in assertions cased_funcs = [function(f + '()') for f in cased_funcs] cased_tbls = [table(t) for t in (cased_tbls + ['"Users"', '"select"'])] cased_rels = [view(t) for t in cased_views] + cased_funcs + cased_tbls cased_users_cols = [column(c) for c in cased_users_cols] aliased_rels = [table(t) for t in ('users u', '"Users" U', 'orders o', '"select" s')] + [view('user_emails ue')] + [function(f) for f in ( '_custom_fun() cf', 'custom_fun() cf', 'custom_func1() cf', 'custom_func2() cf', 'set_returning_func() srf')] cased_aliased_rels = [table(t) for t in ('Users U', '"Users" U', 'Orders O', '"select" s')] + [view('User_Emails UE')] + [function(f) for f in ( '_custom_fun() cf', 'Custom_Fun() CF', 'Custom_Func1() CF', 'custom_func2() cf', 'set_returning_func() srf')] @pytest.fixture def completer(): return testdata.completer