Ejemplo n.º 1
0
 def test_add_duplicate_download(self):
     """
     Testing whether a DuplicateDownloadException is raised when a download is added twice
     """
     self.lm.downloads = {"abcd": None}
     tdef = TorrentDef()
     tdef.metainfo_valid = True
     tdef.infohash = "abcd"
     self.lm.add(tdef, None)
Ejemplo n.º 2
0
    def test_get_index(self):
        t = TorrentDef()
        t.metainfo_valid = True
        t.metainfo = {'info': {'files': [{'path': ['a.txt'], 'length': 123}]}}
        self.assertEqual(t.get_index_of_file_in_files('a.txt'), 0)
        self.assertRaises(ValueError, t.get_index_of_file_in_files, 'b.txt')
        self.assertRaises(ValueError, t.get_index_of_file_in_files, None)

        t.metainfo = {'info': {'files': [{'path': ['a.txt'], 'path.utf-8': ['b.txt'], 'length': 123}]}}
        self.assertEqual(t.get_index_of_file_in_files('b.txt'), 0)
Ejemplo n.º 3
0
    def test_get_index(self):
        t = TorrentDef()
        t.metainfo_valid = True
        t.metainfo = {'info': {'files': [{'path': ['a.txt'], 'length': 123}]}}
        self.assertEqual(t.get_index_of_file_in_files('a.txt'), 0)
        self.assertRaises(ValueError, t.get_index_of_file_in_files, 'b.txt')
        self.assertRaises(ValueError, t.get_index_of_file_in_files, None)

        t.metainfo = {
            'info': {
                'files': [{
                    'path': ['a.txt'],
                    'path.utf-8': ['b.txt'],
                    'length': 123
                }]
            }
        }
        self.assertEqual(t.get_index_of_file_in_files('b.txt'), 0)