def test_collapse_personal_schemas(cursor, objects, expected):
    dbcontext = DatabaseContext(cursor, verbose=True)
    actual = core_generate.collapse_personal_schemas(role='role0',
                                                     objects=objects,
                                                     objkind='tables',
                                                     dbcontext=dbcontext)
    assert actual == expected
def test_collapse_personal_schemas_no_personal_schemas_exist(cursor):
    objects = set(['role1.*', 'role2.foo', 'role3.bar'])
    dbcontext = DatabaseContext(cursor, verbose=True)
    actual = core_generate.collapse_personal_schemas(role='role0',
                                                     objects=objects,
                                                     objkind='tables',
                                                     dbcontext=dbcontext)
    assert actual == objects
def test_collapse_personal_schemas_empty_schema_with_default_priv(cursor):
    dbcontext = DatabaseContext(cursor, verbose=True)
    objects = set([ObjectName('role1', '*'), ObjectName('role2', '*')])
    actual = core_generate.collapse_personal_schemas(role='role0',
                                                     objects=objects,
                                                     objkind='tables',
                                                     dbcontext=dbcontext)
    expected = set([ObjectName('personal_schemas', '*')])
    assert actual == expected
def test_collapse_personal_schemas_no_personal_schemas_exist(cursor):
    objects = set([
        ObjectName('role1', '*'),
        ObjectName('role2', 'foo'),
        ObjectName('role3', 'bar')
    ])
    dbcontext = DatabaseContext(cursor, verbose=True)
    actual = core_generate.collapse_personal_schemas(role='role0',
                                                     objects=objects,
                                                     objkind='tables',
                                                     dbcontext=dbcontext)
    assert actual == objects