* fixed tests for plxrn attributes.
returns = Parameter(int, "1 if successful")
def call(self, xrn, creds, type):
- xrn=Xrn(xrn=xrn,type=type)
+ xrn=Xrn(xrn,type=type)
# validate the cred
valid_creds = self.api.auth.checkCredentials(creds, "remove")
def email_to_hrn (auth_hrn, email):
return PlXrn(auth=auth_hrn, email=email).get_hrn()
def hrn_to_pl_slicename (hrn):
- return PlXrn(hrn=hrn,type='slice').pl_slicename()
+ return PlXrn(xrn=hrn,type='slice').pl_slicename()
def hrn_to_pl_login_base (hrn):
- return PlXrn(hrn=hrn,type='slice').pl_login_base()
+ return PlXrn(xrn=hrn,type='slice').pl_login_base()
def hrn_to_pl_authname (hrn):
- return PlXrn(hrn=hrn,type='any').pl_authname()
+ return PlXrn(xrn=hrn,type='any').pl_authname()
class PlXrn (Xrn):
from sfa.util.sfalogging import sfa_logger
# for convenience and smoother translation - we should get rid of these functions eventually
-def get_leaf(hrn): return Xrn(xrn=hrn).get_leaf()
-def get_authority(hrn): return Xrn(xrn=hrn).get_authority_hrn()
-def urn_to_hrn(urn): xrn=Xrn(xrn=urn); return (xrn.hrn, xrn.type)
-def hrn_to_urn(hrn,type): return Xrn(hrn=hrn, type=type).urn
+def get_leaf(hrn): return Xrn(hrn).get_leaf()
+def get_authority(hrn): return Xrn(hrn).get_authority_hrn()
+def urn_to_hrn(urn): xrn=Xrn(urn); return (xrn.hrn, xrn.type)
+def hrn_to_urn(hrn,type): return Xrn(hrn, type=type).urn
class Xrn:
# self.type
# self.path
# provide either urn, or (hrn + type)
- def __init__ (self, xrn=None, urn=None, hrn=None, type=None):
+ def __init__ (self, xrn, type=None):
# user has specified xrn : guess if urn or hrn
if xrn is not None:
if xrn.startswith(Xrn.URN_PREFIX):
+ self.hrn=None
self.urn=xrn
self.urn_to_hrn()
else:
+ self.urn=None
self.hrn=xrn
self.type=type
self.hrn_to_urn()
- # user has specified urn, let's use it
- elif urn is not None:
- self.urn=urn
- self.urn_to_hrn()
- # user has specified hrn and type
- elif hrn is not None and type is not None:
- self.hrn=hrn
- self.type=type
- self.hrn_to_urn()
- # what should we do ?
else:
raise SfaAPIError,"Xrn.__init__"
# happens all the time ..
def __hrn(self,h,t,exp_urn):
if verbose: print 'testing (',h,t,') expecting',exp_urn
if exp_urn:
- xrn=Xrn(hrn=h,type=t)
+ xrn=Xrn(h,type=t)
if verbose: print xrn.dump_string()
urn=xrn.get_urn()
- (h1,t1) = Xrn(urn=urn).get_hrn_type()
+ (h1,t1) = Xrn(urn).get_hrn_type()
if h1!=h or t1!=t or urn!=exp_urn:
print "hrn->urn->hrn : MISMATCH with in=(%s,%s) -- out=(%s,%s) -- urn=%s"%(h,t,h1,t1,urn)
self.assertEqual(h1,h)
else:
# could not figure how to use assertFails on object construction..
# with self.assertRaises(SfaAPIError):
- # Xrn(hrn=h,type=t).get_urn()
+ # Xrn(h,type=t).get_urn()
try:
- Xrn(hrn=h,type=t).get_urn()
+ Xrn(h,type=t).get_urn()
failure="Unexpectedly created Xrn object"
except SfaAPIError:
failure=False
def test_login_base_001 (self):
- xrn=PlXrn(hrn='ple.inria.omftest',type='slice')
- self.assertEqual(xrn.login_base(),'inria')
+ xrn=PlXrn(xrn='ple.inria.omftest',type='slice')
+ self.assertEqual(xrn.pl_login_base(),'inria')
def test_slicename_001 (self):
- xrn=PlXrn(hrn='ple.inria.omftest',type='slice')
- self.assertEqual(xrn.slicename(),'inria_omftest')
+ xrn=PlXrn(xrn='ple.inria.omftest',type='slice')
+ self.assertEqual(xrn.pl_slicename(),'inria_omftest')
def test_authname_001 (self):
- xrn=PlXrn(hrn='ple.inria.omftest',type='slice')
- self.assertEqual(xrn.authname(),'inria')
+ xrn=PlXrn(xrn='ple.inria.omftest',type='slice')
+ self.assertEqual(xrn.pl_authname(),'inria')