Ejemplo n.º 1
0
 def testValidateExchangeObject(self):
     """Test fetch exchange objects"""
     try:
         #
         sD = self.__mU.doImport(self.__jsonSchemaPath, "json")
         #
         fobj = UniProtUtils(saveText=False)
         idList = self.__unpIdList1
         retD, _ = fobj.fetchList(idList,
                                  usePrimary=self.__usePrimary,
                                  retryAltApi=self.__retryAltApi)
         #
         exObjD = fobj.reformat(retD, formatType="exchange")
         if exObjD and self.__export:
             for rId in exObjD:
                 self.__mU.doExport(os.path.join(self.__workPath,
                                                 rId + "-exchange.json"),
                                    exObjD[rId],
                                    fmt="json",
                                    indent=3)
         #
         Draft4Validator.check_schema(sD)
         #
         valInfo = Draft4Validator(sD, format_checker=FormatChecker())
         eCount = 0
         for rId, dD in exObjD.items():
             logger.debug("Uid %s", rId)
             try:
                 cCount = 0
                 for error in sorted(valInfo.iter_errors(dD), key=str):
                     logger.info("%s path %s error: %s", rId, error.path,
                                 error.message)
                     logger.debug(">>> failing object is %r", dD)
                     eCount += 1
                     cCount += 1
                 #
                 logger.debug("%s errors count %d", rId, cCount)
             except Exception as e:
                 logger.exception("Validator fails  %s", str(e))
         #
         logger.debug("Total errors count %d", eCount)
     except Exception as e:
         logger.exception("Failing with %s", str(e))
         self.fail()
Ejemplo n.º 2
0
 def testExchangeObject(self):
     """Test fetch exchange objects"""
     try:
         #
         fobj = UniProtUtils(saveText=False)
         idList = self.__unpIdList1
         retD, _ = fobj.fetchList(idList,
                                  usePrimary=self.__usePrimary,
                                  retryAltApi=self.__retryAltApi)
         exObjD = fobj.reformat(retD, formatType="exchange")
         if exObjD and self.__export:
             for rId in exObjD:
                 self.__mU.doExport(os.path.join(self.__workPath,
                                                 rId + "-exchange.json"),
                                    exObjD[rId],
                                    fmt="json",
                                    indent=3)
     except Exception as e:
         logger.exception("Failing with %s", str(e))
         self.fail()
 def getDocuments(self, formatType="exchange"):
     fobj = UniProtUtils(saveText=False)
     exObjD = fobj.reformat(self.__refD, formatType=formatType)
     return list(exObjD.values())