示例#1
0
 def testCreateStatusRecord(self):
     """ Verify time stamp operations.
     """
     try:
         dL = []
         desp = DataExchangeStatus()
         ok = desp.setObject("my_database", "my_collection")
         self.assertTrue(ok)
         tS = desp.setStartTime()
         self.assertGreaterEqual(len(tS), 15)
         time.sleep(1)
         ok = desp.setStatus(updateId=None, successFlag="Y")
         self.assertTrue(ok)
         tS = desp.setEndTime()
         self.assertGreaterEqual(len(tS), 15)
         dL.append(desp.getStatus())
         self.assertEqual(len(dL), 1)
         logger.debug("Status record %r", dL[0])
         #
         ok = desp.setObject("my_database", "my_other_collection")
         self.assertTrue(ok)
         tS = desp.setStartTime()
         self.assertGreaterEqual(len(tS), 15)
         time.sleep(1)
         ok = desp.setStatus(updateId="2018_40", successFlag="Y")
         self.assertTrue(ok)
         tS = desp.setEndTime()
         self.assertGreaterEqual(len(tS), 15)
         dL.append(desp.getStatus())
         self.assertEqual(len(dL), 2)
     except Exception as e:
         logger.exception("Failing with %s", str(e))
         self.fail()
示例#2
0
 def __updateStatus(self, updateId, databaseName, collectionName, status,
                    startTimestamp):
     try:
         sFlag = "Y" if status else "N"
         desp = DataExchangeStatus()
         desp.setStartTime(tS=startTimestamp)
         desp.setObject(databaseName, collectionName)
         desp.setStatus(updateId=updateId, successFlag=sFlag)
         desp.setEndTime()
         self.__statusList.append(desp.getStatus())
         return True
     except Exception as e:
         logger.exception("Failing with %s", str(e))
     return False
    def testLoadExchangeStatus(self):
        """ Test case - load data exchange status objects.

        [data_exchange]
        DATABASE_NAME=data_exchange
        DATABASE_VERSION_STRING=v5
        COLLECTION_UPDATE_STATUS=rcsb_data_exchange_status
        COLLECTION_VERSION_STRING=v0_1

        """
        try:
            for ii in range(1, 100):
                collectionName = "my_collection_" + str(ii)
                dList = []
                desp = DataExchangeStatus()
                tS = desp.setStartTime()
                self.assertGreaterEqual(len(tS), 15)
                ok = desp.setObject("my_database", collectionName)
                self.assertTrue(ok)
                ok = desp.setStatus(updateId=None, successFlag="Y")
                self.assertTrue(ok)
                #
                tS = desp.setEndTime()
                self.assertGreaterEqual(len(tS), 15)
                dList.append(desp.getStatus())
                #
                self.assertEqual(len(dList), 1)
                logger.debug("Status record %r", dList[0])

                sectionName = "data_exchange_configuration"
                dl = DocumentLoader(
                    self.__cfgOb,
                    self.__cachePath,
                    self.__resourceName,
                    numProc=self.__numProc,
                    chunkSize=self.__chunkSize,
                    documentLimit=self.__documentLimit,
                    verbose=self.__verbose,
                    readBackCheck=self.__readBackCheck,
                )
                #
                databaseName = self.__cfgOb.get("DATABASE_NAME", sectionName=sectionName)
                # collectionVersion = self.__cfgOb.get('COLLECTION_VERSION_STRING', sectionName=sectionName)
                collectionName = self.__cfgOb.get("COLLECTION_UPDATE_STATUS", sectionName=sectionName)
                if ii == 1:
                    loadType = "full"
                else:
                    loadType = "append"
                ok = dl.load(databaseName, collectionName, loadType=loadType, documentList=dList, indexAttributeList=["update_id", "database_name", "object_name"], keyNames=None)
                self.assertTrue(ok)
                #

        except Exception as e:
            logger.exception("Failing with %s", str(e))
            self.fail()