Beispiel #1
0
 def test_filename_checker_true(self):
     torrent_dir = "./datastore/"
     torrent = Torrent.Torrent(
         hash="55a8925a8d546b9ca47d309ab438b91f7959e77f",
         torrent_dir=torrent_dir).get_from_file()
     ret = utils.filenames_present(torrent, torrent_dir)
     self.assertTrue(ret)
Beispiel #2
0
 def test_stop_message_finished(self):
     torrent = Torrent.Torrent("55a8925a8d546b9ca47d309ab438b91f7959e77f",
                               "./tests/")
     q = Queue()
     tracker = Tracker.Tracker(torrent, q, torrent.total_length)
     params, resp = tracker.stop_message()
     self.assertTrue(resp.status_code == 200)
     self.assertTrue(params['event'] == 'completed')
Beispiel #3
0
 def test_stop_message_already_downloaded(self):
     torrent = Torrent.Torrent("55a8925a8d546b9ca47d309ab438b91f7959e77f",
                               "./tests/")
     q = Queue()
     tracker = Tracker.Tracker(torrent, q)
     downloaded = 0
     remaining = 0
     self.assertTrue(tracker.stop_message(downloaded, remaining))
Beispiel #4
0
 def test_stop_message_finished(self):
     torrent = Torrent.Torrent("55a8925a8d546b9ca47d309ab438b91f7959e77f",
                               "./tests/")
     q = Queue()
     tracker = Tracker.Tracker(torrent, q)
     downloaded = 47622171
     remaining = 0
     params, resp = tracker.stop_message(downloaded, remaining)
     self.assertTrue(resp.status_code == 200)
     self.assertTrue(params['event'] == 'finished')
Beispiel #5
0
    def test_init(self):
        torrent_dir = "tests/"
        torrent = Torrent.Torrent("55a8925a8d546b9ca47d309ab438b91f7959e77f", torrent_dir)
        torrent.numberOfPieces = 3
        torrent.totalLength = 12
        torrent.pieceLength = 4
        torrent.fileNames = [{'length': 12, 'path': 'tests/vangogh.tar.gz'}]
        torrent.pieces = b"\xae\x04\xf4\xbaT\xb8\xe2O\xa6!\xfa\xf4\x97\x94+\x86"
        pieces_manager = PiecesManager.PiecesManager(torrent)
        self.assertTrue(len(pieces_manager.pieces) == 3)
        self.assertTrue(len(pieces_manager.pieces[0].files) == 1)
        self.assertTrue(pieces_manager.pieces[0].files[0].get('pieceOffset')==0)
        self.assertTrue(pieces_manager.pieces[1].files[0].get('pieceOffset')==0)
        self.assertTrue(pieces_manager.pieces[2].files[0].get('pieceOffset')==0)

        self.assertTrue(pieces_manager.pieces[0].files[0].get('fileOffset')==0)
        self.assertTrue(pieces_manager.pieces[1].files[0].get('fileOffset')==4)
        self.assertTrue(pieces_manager.pieces[2].files[0].get('fileOffset')==8)
Beispiel #6
0
 def test_load_from_file(self):
     contents = Torrent.Torrent(
         hash="55a8925a8d546b9ca47d309ab438b91f7959e77f",
         datastore="./tests/").contents
     self.assertTrue(len(contents) == 7)
Beispiel #7
0
 def test_get_pieces(self):
     # TODO: rewrite piecesmanager to be instantiable without an internet connection cause I'm on a freakin' plane.
     torrent_dir = "tests/"
     torrent = Torrent.Torrent("55a8925a8d546b9ca47d309ab438b91f7959e77f", torrent_dir)
     piecesManager = PiecesManager.PiecesManager(torrent)
     assert True
Beispiel #8
0
 def test_filename_checker_true(self):
     torrent = Torrent.Torrent(
         hash="55a8925a8d546b9ca47d309ab438b91f7959e77f",
         datastore="~/.academictorrents-datastore/")
     self.assertTrue(utils.filenames_present(torrent))
Beispiel #9
0
 def test_filename_checker(self):
     torrent = Torrent.Torrent(
         hash="55a8925a8d546b9ca47d309ab438b91f7959e77f",
         datastore="./tests/")
     self.assertFalse(utils.filenames_present(torrent))
Beispiel #10
0
 def test_stop_message_already_downloaded(self):
     torrent = Torrent.Torrent("55a8925a8d546b9ca47d309ab438b91f7959e77f",
                               "./tests/")
     q = Queue()
     tracker = Tracker.Tracker(torrent, q, torrent.total_length)
     self.assertTrue(tracker.stop_message())