def test_determine_schema_privileges_only_read_exists(cursor): dbcontext = DatabaseContext(cursor, verbose=True) actual = core_generate.determine_schema_privileges('role0', dbcontext) expected = { 'read': set([ObjectName('schema0')]), } assert actual == expected
def test_determine_schema_privileges_only_write_exists(cursor): dbcontext = DatabaseContext(cursor, verbose=True) actual = core_generate.determine_schema_privileges('role0', dbcontext) expected = { 'write': ['schema0', 'schema1'], } assert actual == expected
def test_determine_schema_privileges_both_read_and_write_no_personal_schemas( cursor): dbcontext = DatabaseContext(cursor, verbose=True) actual = core_generate.determine_schema_privileges('role0', dbcontext) expected = { 'write': ['schema2', 'schema3'], 'read': ['schema0', 'schema1'], } assert actual == expected
def test_determine_schema_privileges_personal_schemas(cursor): """ Setup: (schema - privilege - expected state) role0 - owns - does not need granting as this is a personal schema owned by this user role1 - read - should be converted to 'personal_schemas' role2 - read - should be converted to 'personal_schemas' schema0 - read - should be in 'read' schema1 - write - should be in 'write' """ dbcontext = DatabaseContext(cursor, verbose=True) actual = core_generate.determine_schema_privileges('role0', dbcontext) expected = { 'write': ['schema1'], 'read': ['personal_schemas', 'schema0'], } assert actual == expected
def test_determine_schema_privileges_has_personal_schema(cursor): dbcontext = DatabaseContext(cursor, verbose=True) actual = core_generate.determine_schema_privileges('role0', dbcontext) assert actual == {}
def test_determine_schema_privileges_nothing_returns(cursor): dbcontext = DatabaseContext(cursor, verbose=True) actual = core_generate.determine_schema_privileges('role0', dbcontext) assert actual == {}