Пример #1
0
    def test_torrent_store_delete(self):
        config = TriblerConfig()
        config.set_state_dir(self.getStateDir())
        config.set_torrent_store_enabled(True)
        session = Session(config, ignore_singleton=True)
        # Manually set the torrent store as we don't want to start the session.
        session.lm.torrent_store = LevelDbStore(
            session.config.get_torrent_store_dir())
        session.lm.torrent_store[hexlify("fakehash")] = "Something"
        self.assertEqual("Something",
                         session.lm.torrent_store[hexlify("fakehash")])
        session.delete_collected_torrent("fakehash")

        raised_key_error = False
        # This structure is needed because if we add a @raises above the test, we cannot close the DB
        # resulting in a dirty reactor.
        try:
            self.assertRaises(KeyError,
                              session.lm.torrent_store[hexlify("fakehash")])
        except KeyError:
            raised_key_error = True
        finally:
            session.lm.torrent_store.close()

        self.assertTrue(raised_key_error)
Пример #2
0
    def test_torrent_store_delete(self):
        config = TriblerConfig()
        config.set_state_dir(self.getStateDir())
        config.set_torrent_store_enabled(True)
        session = Session(config)
        # Manually set the torrent store as we don't want to start the session.
        session.lm.torrent_store = LevelDbStore(session.config.get_torrent_store_dir())
        session.lm.torrent_store[hexlify("fakehash")] = "Something"
        self.assertEqual("Something", session.lm.torrent_store[hexlify("fakehash")])
        session.delete_collected_torrent("fakehash")

        raised_key_error = False
        # This structure is needed because if we add a @raises above the test, we cannot close the DB
        # resulting in a dirty reactor.
        try:
            self.assertRaises(KeyError,session.lm.torrent_store[hexlify("fakehash")])
        except KeyError:
            raised_key_error = True
        finally:
            session.lm.torrent_store.close()

        self.assertTrue(raised_key_error)
Пример #3
0
 def test_torrent_store_not_enabled(self):
     config = TriblerConfig()
     config.set_state_dir(self.getStateDir())
     config.set_torrent_store_enabled(False)
     session = Session(config, ignore_singleton=True)
     session.delete_collected_torrent(None)
Пример #4
0
 def test_torrent_store_not_enabled(self):
     config = TriblerConfig()
     config.set_state_dir(self.getStateDir())
     config.set_torrent_store_enabled(False)
     session = Session(config)
     session.delete_collected_torrent(None)
Пример #5
0
 def test_torrent_store_not_enabled(self):
     config = SessionStartupConfig()
     config.set_torrent_store(False)
     session = Session(config, ignore_singleton=True)
     session.delete_collected_torrent(None)