def testListTorrents(self): ip = self.lt.ip url = "http://%s:%s/list_torrents" % (ip, PORT) code, result = post(url, self.lt.data) #print code, result self.assertEqual(result['ret'], 4) print json.dumps(result['msg'], indent=4)
def testRsync(self): ip = self.rs.ip #url = HOST + "/rsync" url = "http://%s:%s/rsync" % (ip, PORT) code, msg = post(url, self.rs.data) print code, msg self.assertEqual(code, 0) task_id = msg['task_id'] status = QueryTaskTest(ip, task_id).waitForOver() self.assertEqual(status["ret"], TaskStatus(task_id).SUCC["ret"])
def testMakeTorrent(self): ip = self.mt.ip #url = HOST + "/make_torrent" url = "http://%s:%s/make_torrent" % (ip, PORT) code, msg = post(url, self.mt.data) print code, msg self.assertEqual(code, 0) task_id = msg['task_id'] status = QueryTaskTest(ip, task_id).waitForOver() #self.assertEqual(status["ret"], TaskStatus(task_id).SUCC["ret"]) #self.assertIn(status["ret"], (TaskStatus(task_id).SUCC["ret"], -1)) self.assertTrue(status["ret"] in (TaskStatus(task_id).SUCC["ret"], -1))
def testCancelTask(self): ip = self.ct.ip url = "http://%s:%s/cancel_task" % (ip, PORT) code, result = post(url, self.ct.data) print code, result self.assertEqual(result['ret'], 4)
def testQueryTorrent(self): url = "http://%s:%s/query_torrent?torrent_id=%s" \ % (self.ip, PORT, self.torrent_id) #url = MC + "/query_torrent" + "?torrent_id=%s" % self.torrent_id code, status = post(url) return status
def testRemoveTorrent(self): ip = self.rt.ip url = "http://%s:%s/remove_torrent" % (ip, PORT) code, result = post(url, self.rt.data) print code, result self.assertEqual(result['ret'], 4)
def testQueryTask(self): #url = HOST + "/query_task" + "?task_id=%s" % self.task_id url = "http://%s:%s/query_task?task_id=%s" \ % (self.ip, PORT, self.task_id) code, status = post(url) return status