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


Python MockObject.notifier方法代码示例

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


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

示例1: test_monitor_downloads_recreate_ip

# 需要导入模块: from Tribler.Test.Core.base_test import MockObject [as 别名]
# 或者: from Tribler.Test.Core.base_test.MockObject import notifier [as 别名]
    def test_monitor_downloads_recreate_ip(self):
        """
        Test whether an old introduction point is recreated
        """
        tribler_session = MockObject()
        tribler_session.notifier = MockObject()
        tribler_session.notifier.notify = lambda *_: None
        tribler_session.lm = MockObject()
        tribler_session.lm.ltmgr = MockObject()
        tribler_session.lm.ltmgr.get_libtorrent_version = lambda: "1.1.0.0"
        self.nodes[0].overlay.tribler_session = tribler_session

        mock_state = MockObject()
        mock_download = MockObject()
        mock_tdef = MockObject()
        mock_tdef.get_infohash = lambda: 'a'
        mock_download.get_hops = lambda: 1
        mock_download.get_def = lambda: mock_tdef
        mock_download.add_peer = lambda x: None
        mock_download.get_state = lambda: mock_state
        mock_state.get_status = lambda: 1
        mock_state.get_download = lambda: mock_download
        tribler_session.get_downloads = lambda: [mock_download, ]

        real_ih = self.nodes[0].overlay.get_lookup_info_hash('a')
        self.nodes[0].overlay.infohash_ip_circuits[real_ih] = [(3, 0)]
        self.nodes[0].overlay.download_states['a'] = 3
        self.nodes[0].overlay.monitor_downloads([mock_state])
        self.assertNotEqual(self.nodes[0].overlay.infohash_ip_circuits[real_ih][0][1], 0)
开发者ID:Tribler,项目名称:tribler,代码行数:31,代码来源:test_community.py

示例2: setUp

# 需要导入模块: from Tribler.Test.Core.base_test import MockObject [as 别名]
# 或者: from Tribler.Test.Core.base_test.MockObject import notifier [as 别名]
    def setUp(self):
        super(TestContentRepositoryWithRealDatabase, self).setUp()

        session_base_dir = self.temporary_directory()
        tar = tarfile.open(os.path.join(TESTS_DATA_DIR, 'bak_new_tribler.sdb.tar.gz'), 'r|gz')
        tar.extractall(session_base_dir)
        db_path = os.path.join(session_base_dir, 'bak_new_tribler.sdb')
        self.sqlitedb = SQLiteCacheDB(db_path, busytimeout=BUSYTIMEOUT)

        session = MockObject()
        session.sqlite_db = self.sqlitedb
        session.notifier = MockObject()

        self.torrent_db = TorrentDBHandler(session)
        channel_db = MockObject()
        self.content_repository = ContentRepository(self.torrent_db, channel_db)
开发者ID:synctext,项目名称:tribler,代码行数:18,代码来源:test_repository.py

示例3: test_create_torrent

# 需要导入模块: from Tribler.Test.Core.base_test import MockObject [as 别名]
# 或者: from Tribler.Test.Core.base_test.MockObject import notifier [as 别名]
    def test_create_torrent(self):
        """
        Test the creation of a torrent in the search community
        """
        with open(os.path.join(TESTS_DATA_DIR, "bak_single.torrent"), mode='rb') as torrent_file:
            torrent_data = torrent_file.read()

        mock_session = MockObject()
        mock_session.get_collected_torrent = lambda _: torrent_data
        mock_session.open_dbhandler = lambda _: None
        mock_session.notifier = None
        mock_session.lm = MockObject()
        mock_session.lm.rtorrent_handler = None

        self.search_community.initialize(mock_session)
        self.search_community._torrent_db = MockObject()
        self.search_community._torrent_db.updateTorrent = lambda *_, **ignored: None
        self.assertTrue(self.search_community.create_torrent('a' * 20))
开发者ID:synctext,项目名称:tribler,代码行数:20,代码来源:test_search_community.py


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