def testNoSisSelectionMechanism(self): ''' Manual test without actually starting the thread. ''' return #MAX_TORRENTS = 7 #build request #rated = self._tryRanking(iplist = ['209.34.91.45', '81.19.23.42']) #self.assertTrue(rated['81.19.23.42']>rated['209.34.91.45']) #there should be 2 files inside! cache = DummyCache() mech = LocalFolderSelector(folder="SisClient/Cache/Test/resources") max_torrents = 5 stay_in_torrents = 3 selector = TorrentSelection.TorrentSelection( cache, mech, selection_interval=1, max_torrents=max_torrents, stay_in_torrents=stay_in_torrents) #PRE_CONDITION assert len(cache.running) == 0 # fill up to the max joined = selector.get_torrents() assert joined == max_torrents, joined assert len(cache.running) == max_torrents #print "Now running:", cache.running # now replace some of them joined = selector.get_torrents() assert joined == max_torrents - stay_in_torrents assert len(cache.running) == max_torrents # now check if there is too much space for id in cache.running.keys()[0:-2]: cache.leave_swarm(id) assert len(cache.running) == 2 joined = selector.get_torrents() assert joined == max_torrents - 2 assert len(cache.running) == max_torrents