当前位置: 首页>>代码示例>>Python>>正文


Python UnitOfWorkDao.remove方法代码示例

本文整理汇总了Python中synergy.db.dao.unit_of_work_dao.UnitOfWorkDao.remove方法的典型用法代码示例。如果您正苦于以下问题:Python UnitOfWorkDao.remove方法的具体用法?Python UnitOfWorkDao.remove怎么用?Python UnitOfWorkDao.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在synergy.db.dao.unit_of_work_dao.UnitOfWorkDao的用法示例。


在下文中一共展示了UnitOfWorkDao.remove方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: UowLogHandlerUnitTest

# 需要导入模块: from synergy.db.dao.unit_of_work_dao import UnitOfWorkDao [as 别名]
# 或者: from synergy.db.dao.unit_of_work_dao.UnitOfWorkDao import remove [as 别名]
class UowLogHandlerUnitTest(unittest.TestCase):
    """ Test flow:
        1. create a UOW in the database
        2. emulate mq message
        3. call _mq_callback method
        4. validate that all the messages are now found in the uow_log record
        5. remove UOW and uow_log record
    """

    def setUp(self):
        self.process_name = PROCESS_ALERT_DAILY
        self.logger = get_logger(self.process_name)
        self.uow_id = create_and_insert_unit_of_work(self.process_name, 'range_start', 'range_end')
        self.uow_id = str(self.uow_id)
        self.uow_dao = UnitOfWorkDao(self.logger)
        self.uow_log_dao = UowLogDao(self.logger)

    def tearDown(self):
        self.uow_dao.remove(self.uow_id)
        self.uow_log_dao.remove(self.uow_id)

    def test_logging(self):
        self.worker = ChattyWorker(self.process_name)
        message = TestMessage(process_name=self.process_name, uow_id=self.uow_id)
        self.worker._mq_callback(message)

        uow_log = self.uow_log_dao.get_one(self.uow_id)
        messages = INFO_LOG_MESSAGES + WARN_LOG_MESSAGES  # + STD_MESSAGES
        self.assertLessEqual(len(messages), len(uow_log.log))

        for index, message in enumerate(messages):
            self.assertIn(message, uow_log.log[index])

    def test_exception_logging(self):
        self.worker = ExceptionWorker(self.process_name)
        message = TestMessage(process_name=self.process_name, uow_id=self.uow_id)
        self.worker._mq_callback(message)

        uow_log = self.uow_log_dao.get_one(self.uow_id)
        messages = ['Exception: Artificially triggered exception to test Uow Exception Logging',
                    'method ExceptionWorker._process_uow returned None. Assuming happy flow.',
                    'at INVALID_TIMEPERIOD: Success/Failure 0/0']

        for index, message in enumerate(messages):
            self.assertIn(message, uow_log.log[index])
开发者ID:xiaohuangji,项目名称:scheduler,代码行数:47,代码来源:test_uow_log_handler.py

示例2: test_select_reprocessing_candidates

# 需要导入模块: from synergy.db.dao.unit_of_work_dao import UnitOfWorkDao [as 别名]
# 或者: from synergy.db.dao.unit_of_work_dao.UnitOfWorkDao import remove [as 别名]
    def test_select_reprocessing_candidates(self):
        logger = get_logger(PROCESS_UNIT_TEST)
        uow_dao = UnitOfWorkDao(logger)

        try:
            initial_candidates = uow_dao.get_reprocessing_candidates()
        except:
            initial_candidates = []

        try:
            initial_positive_candidates = uow_dao.get_reprocessing_candidates('2010123123')
        except:
            initial_positive_candidates = []

        positive_timeperiods = {u'2010123123': PROCESS_SITE_HOURLY,    # hourly time qualifier
                                u'2010123100': PROCESS_SITE_DAILY,     # daily time qualifier
                                u'2010120000': PROCESS_SITE_MONTHLY,   # monthly time qualifier
                                u'2010000000': PROCESS_SITE_YEARLY}    # yearly time qualifier

        negative_timeperiods = {u'2009123123': PROCESS_SITE_HOURLY,    # hourly time qualifier
                                u'2009123100': PROCESS_SITE_DAILY,     # daily time qualifier
                                u'2009120000': PROCESS_SITE_MONTHLY,   # monthly time qualifier
                                u'2009000000': PROCESS_SITE_YEARLY}    # yearly time qualifier

        all_timeperiods = dict()
        all_timeperiods.update(positive_timeperiods)
        all_timeperiods.update(negative_timeperiods)

        created_uow = []
        for timeperiod, process_name in all_timeperiods.items():
            created_uow.append(create_and_insert_unit_of_work(process_name,
                                                              0,
                                                              1,
                                                              timeperiod=timeperiod,
                                                              state=unit_of_work.STATE_INVALID))

        candidates = uow_dao.get_reprocessing_candidates('2010123123')
        self.assertEqual(len(candidates) - len(initial_positive_candidates), len(positive_timeperiods))

        candidates = uow_dao.get_reprocessing_candidates()
        self.assertEqual(len(candidates) - len(initial_candidates), len(all_timeperiods))

        for uow_id in created_uow:
            uow_dao.remove(uow_id)
开发者ID:eggsandbeer,项目名称:scheduler,代码行数:46,代码来源:test_garbage_collector.py

示例3: tearDown

# 需要导入模块: from synergy.db.dao.unit_of_work_dao import UnitOfWorkDao [as 别名]
# 或者: from synergy.db.dao.unit_of_work_dao.UnitOfWorkDao import remove [as 别名]
 def tearDown(self):
     # cleaning up DB
     self.virtual_tear_down()
     uow_dao = UnitOfWorkDao(self.aggregator.logger)
     uow_dao.remove(self.uow_id)
     del self.aggregator
开发者ID:eggsandbeer,项目名称:scheduler,代码行数:8,代码来源:test_abstract_worker.py


注:本文中的synergy.db.dao.unit_of_work_dao.UnitOfWorkDao.remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。