Ejemplo n.º 1
0
 def testValid(self):
     t = eApiType.EO_V1
     assert eApiType.isValid(t)
     api_ = ApiFactory.get(t)
     self.apis.append(api_)
     assert isinstance(api_, iApi)
     t = eApiType.EO_V1__HANDLER
     assert eApiType.isValid(t)
     api_ = ApiFactory.get(t)
     self.apis.append(api_)
     assert isinstance(api_, iApi)
Ejemplo n.º 2
0
 def testValid(self):
     t = eApiType.EO_V1
     assert eApiType.isValid(t)
     api_ = ApiFactory.get(t)
     self.apis.append(api_)
     assert isinstance(api_, iApi)
     t = eApiType.EO_V1__HANDLER
     assert eApiType.isValid(t)
     api_ = ApiFactory.get(t)
     self.apis.append(api_)
     assert isinstance(api_, iApi)
Ejemplo n.º 3
0
 def testInvalidType(self):
     t = eApiType.EO_V1 + "hello.world!"
     assert not eApiType.isValid(t)
     try:
         ApiFactory.get(t)
     except ApiParamError, e:
         assert e.item == t
         assert eApiType in e.allowedTypes
         assert len(e.allowedTypes) == 1
Ejemplo n.º 4
0
 def testInvalidType(self):
     t = eApiType.EO_V1 + "hello.world!"
     assert not eApiType.isValid(t)
     try:
         ApiFactory.get(t)
     except ApiParamError, e:
         assert e.item == t
         assert eApiType in e.allowedTypes
         assert len(e.allowedTypes) == 1
 def get(e_api_type, *args, **kwargs):
     r"""
     @param e_api_type: Subjective 'type' of API.
     @see: eApiType.
     """
     if not eApiType.isValid(e_api_type):
         raise ApiParamError(e_api_type, eApiType)
     if e_api_type == eApiType.EO_V1:
         from epyrpc.api.eo_v1.impl.head.Api import api as HeadAPI
         api_ = HeadAPI(*args, **kwargs)
         return api_
     elif e_api_type == eApiType.EO_V1__HANDLER:
         from epyrpc.api.eo_v1.impl.neck.Api import api as NeckAPI
         api_ = NeckAPI(*args, **kwargs)
         return api_
     raise UnknownApiError("%(T)s" % {"T":type(eApiType)})