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


Python MockObject.category方法代码示例

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


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

示例1: test_tracker_warning_alert

# 需要导入模块: from Tribler.Test.Core.base_test import MockObject [as 别名]
# 或者: from Tribler.Test.Core.base_test.MockObject import category [as 别名]
 def test_tracker_warning_alert(self):
     """
     Test whether a tracking warning alert is processed correctly
     """
     url = "http://google.com"
     mock_alert = MockObject()
     mock_alert.category = lambda: lt.alert.category_t.error_notification
     mock_alert.url = url
     mock_alert.message = lambda: 'test'
     self.libtorrent_download_impl.process_alert(mock_alert, 'tracker_warning_alert')
     self.assertEqual(self.libtorrent_download_impl.tracker_status[url][1], 'Warning: test')
开发者ID:synctext,项目名称:tribler,代码行数:13,代码来源:test_libtorrent_download_impl.py

示例2: test_process_error_alert

# 需要导入模块: from Tribler.Test.Core.base_test import MockObject [as 别名]
# 或者: from Tribler.Test.Core.base_test.MockObject import category [as 别名]
    def test_process_error_alert(self):
        """
        Testing whether error alerts are processed correctly
        """
        url = "http://google.com"
        mock_alert = MockObject()
        mock_alert.msg = None
        mock_alert.category = lambda: lt.alert.category_t.error_notification
        mock_alert.status_code = 123
        mock_alert.url = url
        self.libtorrent_download_impl.process_alert(mock_alert, 'tracker_error_alert')
        self.assertEqual(self.libtorrent_download_impl.tracker_status[url][1], 'HTTP status code 123')

        mock_alert.status_code = 0
        self.libtorrent_download_impl.process_alert(mock_alert, 'tracker_error_alert')
        self.assertEqual(self.libtorrent_download_impl.tracker_status[url][1], 'Timeout')
开发者ID:synctext,项目名称:tribler,代码行数:18,代码来源:test_libtorrent_download_impl.py

示例3: test_torrent_checked_alert

# 需要导入模块: from Tribler.Test.Core.base_test import MockObject [as 别名]
# 或者: from Tribler.Test.Core.base_test.MockObject import category [as 别名]
    def test_torrent_checked_alert(self):
        """
        Testing whether the right operations happen after a torrent checked alert is received
        """
        def mocked_pause_checkpoint():
            mocked_pause_checkpoint.called = True

        mocked_pause_checkpoint.called = False
        self.libtorrent_download_impl.handle.pause = mocked_pause_checkpoint
        self.libtorrent_download_impl.checkpoint = mocked_pause_checkpoint

        mock_alert = MockObject()
        mock_alert.category = lambda: lt.alert.category_t.error_notification
        self.libtorrent_download_impl.pause_after_next_hashcheck = True
        self.libtorrent_download_impl.process_alert(mock_alert, 'torrent_checked_alert')
        self.assertFalse(self.libtorrent_download_impl.pause_after_next_hashcheck)
        self.assertTrue(mocked_pause_checkpoint.called)

        mocked_pause_checkpoint.called = False
        self.libtorrent_download_impl.checkpoint_after_next_hashcheck = True
        self.libtorrent_download_impl.process_alert(mock_alert, 'torrent_checked_alert')
        self.assertFalse(self.libtorrent_download_impl.checkpoint_after_next_hashcheck)
        self.assertTrue(mocked_pause_checkpoint.called)
开发者ID:synctext,项目名称:tribler,代码行数:25,代码来源:test_libtorrent_download_impl.py


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