Esempio n. 1
0
 def test_add_list_info_and_remove(self):
     count_before = len(utils.torrent_list())
     self.assertEqual(utils.torrent_add(TORRENT_MAGNET), TRANSMISSION_MSG_SUCCESS)
     self.assertEqual(utils.torrent_add(TORRENT_MAGNET), 'Error: duplicate torrent')
     torrents = utils.torrent_list()
     count_after = len(torrents)
     added_torrent = torrents[-1]
     self.assertTrue(utils.torrent_info(added_torrent.id))
     self.assertEqual(count_after, count_before + 1)
     self.assertEqual(utils.torrent_remove(added_torrent.id), TRANSMISSION_MSG_SUCCESS)
Esempio n. 2
0
def torrent_add(message):
    log.info("Handling command add torrent - %s" % message.text)
    args = message.text.split()
    if len(args) < 2:
        log.warning("Missing torrent URL")
        bot.reply_to(message, "Missing torrent URL. Usage: /add [URL]")
        return
    url = args[1]
    response = utils.torrent_add(url)
    if "success" in response:
        log.info("Torrent added")
        bot.reply_to(message, "Torrent added")
    else:
        log.info("Error adding torrent")
        bot.reply_to(message, response)
Esempio n. 3
0
def torrent_add(message):
    log.info("Handling command add torrent - %s" % message.text)
    args = message.text.split()
    if len(args) < 2:
        log.warn("Missing torrent URL")
        bot.reply_to(message, "Missing torrent URL. Usage: /torrent_add [URL]")
        return
    url = args[1]
    response = utils.torrent_add(url)
    if "success" in response:
        log.info("Torrent added")
        bot.reply_to(message, "Torrent added")
    else:
        log.info("Error adding torrent")
        bot.reply_to(message, response)
Esempio n. 4
0
 def test_torrent_add_invalid(self):
     self.assertEqual(utils.torrent_add("magnet:?xt=urn:btih:2013fdfff"),
                      TRANSMISSION_MSG_ADD_INVALID_TORRENT)
Esempio n. 5
0
 def test_torrent_add_empty(self):
     self.assertEqual(utils.torrent_add(""),
                      TRANSMISSION_MSG_ADD_INVALID_TORRENT)