def test_add_single_file(self): """ Test whether adding a single file to a torrent is working correctly """ t = TorrentDef() torrent_dir = TESTS_DATA_DIR / "contentdir" t.add_content(torrent_dir / "file.txt") t.save() metainfo = t.get_metainfo() self.assertEqual(metainfo[b'info'][b'name'], b'file.txt')
def test_add_content_dir(self): """ Test whether adding a single content directory with two files is working correctly """ t = TorrentDef() torrent_dir = TESTS_DATA_DIR / "contentdir" t.add_content(torrent_dir / "file.txt") t.add_content(torrent_dir / "otherfile.txt") t.save() metainfo = t.get_metainfo() self.assertEqual(len(metainfo[b'info'][b'files']), 2)
def test_add_content_piece_length(self): """ Add a single file with piece length to a TorrentDef """ t = TorrentDef() fn = TESTS_DATA_DIR / VIDEO_FILE_NAME t.add_content(fn) t.set_piece_length(2**16) t.save() metainfo = t.get_metainfo() self.assertEqual(metainfo[b'info'][b'piece length'], 2**16)