Example #1
0
 def test_retrieve_torrentfile(self):
     try:
         filename = '%s/test.torrent' % SCRIPTDIR
         file = open(filename, 'r')
         utils.post_torrentfile(self.client, filename, file)
     finally:
         file.close()
     resp = utils.get_torrentfile(self.client, '%s/test.torrent' % SCRIPTDIR)
     self.assert200(resp)
     self.assertEquals(resp.data, open(filename, 'r').read())
 def test_transfers_with_active_transfer(self):
     '''If a transfer is active, this will return a dict of hashes and their torrentfiles'''
     filename = '%s/test.torrent' % SCRIPTDIR
     try:
         file = open(filename, 'r')
         ihash = utils.get_infohash_from_file(file)
         file.seek(0)
         utils.post_torrentfile(self.client, filename, file)
     except Exception, e:
         log.critical("Cannot open test torrent file")
         self.assertTrue(False, "%s" % e)
Example #3
0
 def test_transfers_with_active_transfer(self):
     '''If a transfer is active, this will return a dict of hashes and their torrentfiles'''
     filename = '%s/test.torrent' % SCRIPTDIR
     try:
         file = open(filename, 'r')
         ihash = utils.get_infohash_from_file(file)
         file.seek(0)
         utils.post_torrentfile(self.client, filename, file)
     except Exception, e:
         log.critical("Cannot open test torrent file")
         self.assertTrue(False, "%s" % e)
Example #4
0
 def test_nonempty_torrents_after_post(self):
     '''test if we get a non-empty list back after we posted a torrent file'''
     try:
         filename = '%s/test.torrent' % SCRIPTDIR
         file = open(filename, 'r')
         utils.post_torrentfile(self.client, filename, file)
     finally:
         file.close()
         resp = self.client.get('torrents/')
         self.assert200(resp)
         assert(len(resp.json.keys()) > 0)
         self.assertEquals(resp.json.keys(), ['test.torrent'])
 def test_stats_with_a_seeder(self):
     filename = '%s/test.torrent' % SCRIPTDIR
     try:
         file = open(filename, 'r')
         ihash = utils.get_infohash_from_file(file)
         transfersize = utils.get_size_from_torrentfile(file)
         file.seek(0)
         utils.post_torrentfile(self.client, filename, file)
     finally:
         file.close()
     try:
         ipaddress = '192.168.0.12'
         rackname = 'FA12'
         utils.add_client(self.app, ihash, ipaddress, rackname, left=0)
     except Exception, e:
         raise e
Example #6
0
 def test_stats_with_a_seeder(self):
     filename = '%s/test.torrent' % SCRIPTDIR
     try:
         file = open(filename, 'r')
         ihash = utils.get_infohash_from_file(file)
         transfersize = utils.get_size_from_torrentfile(file)
         file.seek(0)
         utils.post_torrentfile(self.client, filename, file)
     finally:
         file.close()
     try:
         ipaddress = '192.168.0.12'
         rackname = 'FA12'
         utils.add_client(self.app, ihash, ipaddress, rackname, left=0)
     except Exception, e:
         raise e
Example #7
0
 def test_stopped_event_handling(self):
     '''Test a single peer progress'''
     filename = '%s/test.torrent' % SCRIPTDIR
     try:
         file = open(filename, 'r')
         ihash = utils.get_infohash_from_file(file)
         transfersize = utils.get_size_from_torrentfile(file)
         file.seek(0)
         utils.post_torrentfile(self.client, filename, file)
     finally:
         file.close()
     try:
         ipaddress = '192.168.0.12'
         rackname = 'FA12'
         utils.add_client(self.app, ihash, ipaddress, rackname, left=transfersize, event='stopped', mock_smdb=True)
     except Exception, e:
         raise e
Example #8
0
 def test_post_torrent_correctfilename(self):
     filename = '%s/test.torrent' % SCRIPTDIR
     try:
         file = open(filename, 'r')
         resp = utils.post_torrentfile(self.client, filename, file)
         self.assert200(resp)
     finally:
         file.close()
 def test_stats_progress(self):
     '''Test a single peer progress'''
     filename = '%s/test.torrent' % SCRIPTDIR
     try:
         file = open(filename, 'r')
         ihash = utils.get_infohash_from_file(file)
         transfersize = utils.get_size_from_torrentfile(file)
         file.seek(0)
         utils.post_torrentfile(self.client, filename, file)
     finally:
         file.close()
     try:
         ipaddress = '192.168.0.12'
         rackname = 'FA12'
         utils.add_client(self.app,
                          ihash,
                          ipaddress,
                          rackname,
                          left=transfersize,
                          mock_smdb=True)
     except Exception, e:
         raise e
Example #10
0
 def test_delete_existing_torrentfile(self):
     '''Delete a torrent file from the tracker'''
     try:
         filename = '%s/test.torrent' % SCRIPTDIR
         file = open(filename, 'r')
         resp = utils.post_torrentfile(self.client, filename, file)
         log.debug('resp on post: %s' % resp)
     finally:
         file.close()
     with self.app.test_client() as c:
         resp = c.delete('torrents/test.torrent')
         log.debug('delete resp: %s' % resp)
         log.debug('delet resp data: %s' % resp.data)
         self.assert200(resp)
     resp = utils.get_torrentfile(self.client, filename)
     self.assert404(resp)
Example #11
0
 def test_post_torrent_falsefilename(self):
     resp = utils.post_torrentfile(self.client, 'ramon.txt', None)
     self.assert_status(resp, 501)