示例#1
0
 def test12(self):
     """File.Insert"""
     from dbs.dao.Oracle.File.Insert import Insert as FileInsert
     dao = FileInsert(self.logger, self.dbi)
     dinput = []
     for k in range(10):
         dinput.append({
             "fileid": int(INSERTCOUNT) * 100 + k,
             "logicalfilename": "file_" + INSERTCOUNT + str(k),
             "isfilevalid": True,
             "dataset": 60,
             "block": 37,
             "filetype": 1,
             "checksum": "9999",
             "eventcount": 1000,
             "filesize": 1024,
             "branchhash": 1,
             "adler32": "adler32",
             "md5": "md5",
             "autocrosssection": 234,
             "creationdate": 1234,
             "createby": "*****@*****.**",
             "lastmodificationdate": 12345,
             "lastmodifiedby": "*****@*****.**"
         })
     dao.execute(dinput)
示例#2
0
 def setUp(self):
     """setup all necessary parameters"""
     self.conn = self.dbi.connection()
     self.file_insert = FileInsert(self.logger, self.dbi, self.dbowner)
     self.block_list = BlockList(self.logger, self.dbi, self.dbowner)
     self.dataset_id = DatasetGetID(self.logger, self.dbi, self.dbowner)
     self.file_type_id = FileTypeGetID(self.logger, self.dbi, self.dbowner)
     self.sequence_manager = SequenceManager(self.logger, self.dbi, self.dbowner)
示例#3
0
 def setUp(self):
     """setup all necessary parameters"""
     self.conn = self.dbi.connection()
     self.file_insert = FileInsert(self.logger, self.dbi, self.dbowner)
     self.block_list = BlockList(self.logger, self.dbi, self.dbowner)
     self.dataset_id = DatasetGetID(self.logger, self.dbi, self.dbowner)
     self.file_type_id = FileTypeGetID(self.logger, self.dbi, self.dbowner)
     self.sequence_manager = SequenceManager(self.logger, self.dbi,
                                             self.dbowner)
示例#4
0
 def test12(self):
     """File.Insert"""
     from dbs.dao.Oracle.File.Insert import Insert as FileInsert
     dao = FileInsert(self.logger, self.dbi)
     dinput = []
     for k in range(10):
         dinput.append({"fileid":int(INSERTCOUNT)*100 + k, 
                  "logicalfilename":"file_" + INSERTCOUNT + str(k),
                  "isfilevalid":True, 
                  "dataset":60,
                  "block":37,
                  "filetype":1,
                  "checksum":"9999",
                  "eventcount":1000,
                  "filesize":1024,
                  "branchhash":1,
                  "adler32":"adler32",
                  "md5":"md5",
                  "autocrosssection":234,
                  "creationdate":1234,
                  "createby":"*****@*****.**",
                  "lastmodificationdate":12345,
                  "lastmodifiedby":"*****@*****.**"})
     dao.execute(dinput)
示例#5
0
class Insert_t(unittest.TestCase):
    @DaoConfig("DBSWriter")
    def __init__(self, methodName='runTest'):
        super(Insert_t,self).__init__(methodName)
        data_location = os.path.join(os.path.dirname(os.path.abspath(__file__)),'test_data.pkl')
        self.data_provider = create_dbs_data_provider(data_type='transient',data_location=data_location)
        self.data = self.data_provider.get_file_data(regenerate=True)[0]
        self.child_data = self.data_provider.get_child_file_data(regenerate=True)[0]
        
    def setUp(self):
        """setup all necessary parameters"""
        self.conn = self.dbi.connection()
        self.file_insert = FileInsert(self.logger, self.dbi, self.dbowner)
        self.block_list = BlockList(self.logger, self.dbi, self.dbowner)
        self.dataset_id = DatasetGetID(self.logger, self.dbi, self.dbowner)
        self.file_type_id = FileTypeGetID(self.logger, self.dbi, self.dbowner)
        self.sequence_manager = SequenceManager(self.logger, self.dbi, self.dbowner)
                
    def tearDown(self):
        """Clean-up all necessary parameters"""
        self.conn.close()

    def _insertFile(self, data):
        tran = self.conn.begin()
        
        try:
            data["file_id"] = self.sequence_manager.increment(self.conn, "SEQ_FL", transaction=tran)
            #insert needs an id not the name, whereas list will return the name
            data["dataset_id"] = self.dataset_id.execute(self.conn, dataset=data["dataset"], transaction=tran)
            del data["dataset"]

            #insert needs an id not the name, whereas list will return the name
            block_info = self.block_list.execute(self.conn, block_name=data["block_name"], transaction=tran)
            data["block_id"] = block_info[0]["block_id"]
            del data["block_name"]
            
            #insert needs an id not the name, whereas list will return the name
            data["file_type_id"] = self.file_type_id.execute(self.conn, data["file_type"], transaction=tran)
            del data["file_type"]

            #No more supported, see Ticket #965 YG 
            del data["creation_date"]
            del data["create_by"]
            
            self.file_insert.execute(self.conn, data, transaction=tran)

        except Exception as ex:
            tran.rollback()
            raise ex
        else:
            tran.commit()
        finally:
            if tran:
                tran.close()
    def test01(self):
        """dao.Oracle.File.Insert: Basic"""
        self._insertFile(self.data)

    def test02(self):
        """dao.Oracle.File.Insert: ChildFile"""
        self._insertFile(self.child_data)
示例#6
0
class Insert_t(unittest.TestCase):
    @DaoConfig("DBSWriter")
    def __init__(self, methodName='runTest'):
        super(Insert_t, self).__init__(methodName)
        data_location = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), 'test_data.pkl')
        self.data_provider = create_dbs_data_provider(
            data_type='transient', data_location=data_location)
        self.data = self.data_provider.get_file_data(regenerate=True)[0]
        self.child_data = self.data_provider.get_child_file_data(
            regenerate=True)[0]

    def setUp(self):
        """setup all necessary parameters"""
        self.conn = self.dbi.connection()
        self.file_insert = FileInsert(self.logger, self.dbi, self.dbowner)
        self.block_list = BlockList(self.logger, self.dbi, self.dbowner)
        self.dataset_id = DatasetGetID(self.logger, self.dbi, self.dbowner)
        self.file_type_id = FileTypeGetID(self.logger, self.dbi, self.dbowner)
        self.sequence_manager = SequenceManager(self.logger, self.dbi,
                                                self.dbowner)

    def tearDown(self):
        """Clean-up all necessary parameters"""
        self.conn.close()

    def _insertFile(self, data):
        tran = self.conn.begin()

        try:
            data["file_id"] = self.sequence_manager.increment(self.conn,
                                                              "SEQ_FL",
                                                              transaction=tran)
            #insert needs an id not the name, whereas list will return the name
            data["dataset_id"] = self.dataset_id.execute(
                self.conn, dataset=data["dataset"], transaction=tran)
            del data["dataset"]

            #insert needs an id not the name, whereas list will return the name
            block_info = self.block_list.execute(self.conn,
                                                 block_name=data["block_name"],
                                                 transaction=tran)
            for b in block_info:
                data["block_id"] = b["block_id"]
            del data["block_name"]

            #insert needs an id not the name, whereas list will return the name
            data["file_type_id"] = self.file_type_id.execute(self.conn,
                                                             data["file_type"],
                                                             transaction=tran)
            del data["file_type"]

            #No more supported, see Ticket #965 YG
            del data["creation_date"]
            del data["create_by"]

            self.file_insert.execute(self.conn, data, transaction=tran)

        except Exception as ex:
            tran.rollback()
            raise ex
        else:
            tran.commit()
        finally:
            if tran:
                tran.close()

    def test01(self):
        """dao.Oracle.File.Insert: Basic"""
        self._insertFile(self.data)

    def test02(self):
        """dao.Oracle.File.Insert: ChildFile"""
        self._insertFile(self.child_data)