def test_grant_object(): from ldap2pg.privilege import Privilege, Grant priv = Privilege(name='connect', grant='GRANT {database} TO {role};') item = Grant(priv.name, dbname='backend', schema=None, role='daniel') qry = priv.grant(item) assert 'GRANT "backend"' in qry.args[0] assert 'daniel' in qry.args[0]
def test_grant_object(): from ldap2pg.privilege import Privilege, Grant from ldap2pg.role import Role priv = Privilege(name='connect', grant='GRANT {database} TO {role};') item = Grant(priv.name, dbname='backend', schema=None, role='daniel') qry = priv.grant(item) assert 'GRANT "backend"' in qry.args[0] assert 'daniel' in qry.args[0] assert 'db' in repr(Grant('p', ['db'], ['schema'])) # Test hash with Role object. str_h = hash(Grant('priv', ['db'], ['schema'], role=Role(u'rôle'))) obj_h = hash(Grant('priv', ['db'], ['schema'], role=u'rôle')) assert str_h == obj_h