def test_find_torrent_no_settings(self, qbittorrent_client):
        client = qbittorrent_client.return_value

        torrent_hash = "8347DD6415598A7409DFC3D1AB95078F959BFB93"
        plugin = QBittorrentClientPlugin()

        plugin.find_torrent(torrent_hash)

        client.torrents_info.assert_not_called()
 def test_find_torrent_no_settings(self):
     with patch.object(monitorrent.plugins.clients.qbittorrent.requests.Session, 'post', side_effect=Exception):
         plugin = QBittorrentClientPlugin()
         torrent_hash = "8347DD6415598A7409DFC3D1AB95078F959BFB93"
         settings = {'host': self.bad_host, 'port': self.bad_port, 'username': self.bad_login,
                     'password': self.bad_password}
         plugin.set_settings(settings)
         torrent = plugin.find_torrent(torrent_hash)
         self.assertFalse(torrent)
    def test_find_torrent_failed_with_exception(self, qbittorrent_client):
        client = qbittorrent_client.return_value
        client.torrents_info.side_effect = qbittorrentapi.HTTP500Error

        plugin = QBittorrentClientPlugin()
        torrent_hash = "8347DD6415598A7409DFC3D1AB95078F959BFB93"
        settings = self.DEFAULT_SETTINGS
        plugin.set_settings(settings)
        self.assertFalse(plugin.find_torrent(torrent_hash))
    def test_find_torrent_failed(self, qbittorrent_client):
        client = qbittorrent_client.return_value
        client.torrents_info.return_value = []

        plugin = QBittorrentClientPlugin()
        torrent_hash = "8347DD6415598A7409DFC3D1AB95078F959BFB93"
        settings = self.DEFAULT_SETTINGS
        plugin.set_settings(settings)
        self.assertFalse(plugin.find_torrent(torrent_hash))
    def test_find_torrent(self, get_mock):
        response = Response()
        response._content = b'[{"added_on":"2016-04-09T20:24:17","completion_on":null,"dlspeed":0,"eta":8640000,"f_l_piece_prio":false,"force_start":false,"hash":"d27c8e30f0c12afe84735b57f6463266b118acea","label":"","name":"Ment.v.zakone.9.2015.HDTVRip.Files-x","num_complete":12,"num_incomplete":42,"num_leechs":0,"num_seeds":0,"priority":1,"progress":0.073527365922927856,"ratio":0.022764846784523337,"save_path":"Downloads","seq_dl":false,"size":5776162816,"state":"pausedDL","super_seeding":false,"upspeed":0}]'
        get_mock.return_value = response

        plugin = QBittorrentClientPlugin()
        torrent_hash = "D27C8E30F0C12AFE84735B57F6463266B118ACEA"
        settings = {'host': self.real_host, 'username': self.real_login,
                    'password': self.real_password}
        plugin.set_settings(settings)
        torrent = plugin.find_torrent(torrent_hash)
        self.assertEqual(torrent['date_added'], datetime(2016, 4, 9, 20, 24, 17, tzinfo=pytz.reference.Local))
        self.assertEqual(torrent['name'], 'Ment.v.zakone.9.2015.HDTVRip.Files-x')
    def test_find_torrent_failed(self, post_mock, get_mock):
        response = Response()
        response._content = b"Ok."
        response.status_code = 200
        post_mock.return_value = response
        get_mock.side_effect = Exception('boom')

        plugin = QBittorrentClientPlugin()
        torrent_hash = "8347DD6415598A7409DFC3D1AB95078F959BFB93"
        settings = {'host': self.real_host, 'port': self.real_port, 'username': self.real_login,
                    'password': self.real_password}
        plugin.set_settings(settings)
        torrent = plugin.find_torrent(torrent_hash)
        self.assertFalse(torrent)
Exemple #7
0
 def test_find_torrent_no_settings(self):
     with patch.object(
             monitorrent.plugins.clients.qbittorrent.requests.Session,
             'post',
             side_effect=Exception):
         plugin = QBittorrentClientPlugin()
         torrent_hash = "8347DD6415598A7409DFC3D1AB95078F959BFB93"
         settings = {
             'host': self.bad_host,
             'port': self.bad_port,
             'username': self.bad_login,
             'password': self.bad_password
         }
         plugin.set_settings(settings)
         torrent = plugin.find_torrent(torrent_hash)
         self.assertFalse(torrent)
Exemple #8
0
    def test_find_torrent_for_33_version(self, get_mock):
        response = Response()
        response._content = b'[{"added_on":1481781596,"completion_on":null,"dlspeed":0,"eta":8640000,"f_l_piece_prio":false,"force_start":false,"hash":"d27c8e30f0c12afe84735b57f6463266b118acea","label":"","name":"Ment.v.zakone.9.2015.HDTVRip.Files-x","num_complete":12,"num_incomplete":42,"num_leechs":0,"num_seeds":0,"priority":1,"progress":0.073527365922927856,"ratio":0.022764846784523337,"save_path":"Downloads","seq_dl":false,"size":5776162816,"state":"pausedDL","super_seeding":false,"upspeed":0}]'
        get_mock.return_value = response

        plugin = QBittorrentClientPlugin()
        torrent_hash = "D27C8E30F0C12AFE84735B57F6463266B118ACEA"
        settings = {
            'host': self.real_host,
            'username': self.real_login,
            'password': self.real_password
        }
        plugin.set_settings(settings)
        torrent = plugin.find_torrent(torrent_hash)
        self.assertEqual(torrent['date_added'],
                         datetime(2016, 12, 15, 5, 59, 56, tzinfo=pytz.utc))
        self.assertEqual(torrent['name'],
                         'Ment.v.zakone.9.2015.HDTVRip.Files-x')
Exemple #9
0
    def test_find_torrent_failed(self, post_mock, get_mock):
        response = Response()
        response._content = b"Ok."
        response.status_code = 200
        post_mock.return_value = response
        get_mock.side_effect = Exception('boom')

        plugin = QBittorrentClientPlugin()
        torrent_hash = "8347DD6415598A7409DFC3D1AB95078F959BFB93"
        settings = {
            'host': self.real_host,
            'port': self.real_port,
            'username': self.real_login,
            'password': self.real_password
        }
        plugin.set_settings(settings)
        torrent = plugin.find_torrent(torrent_hash)
        self.assertFalse(torrent)
Exemple #10
0
    def test_find_torrent(self, qbittorrent_client):
        rpc_client = qbittorrent_client.return_value

        torrent_hash = "D27C8E30F0C12AFE84735B57F6463266B118ACEA"
        date_added = datetime(2015, 10, 9, 12, 3, 55, tzinfo=pytz.reference.LocalTimezone())

        plugin = QBittorrentClientPlugin()
        settings = self.DEFAULT_SETTINGS
        plugin.set_settings(settings)

        torrent_info = new('torrent', {'name': 'Torrent 1', 'info': new('info', {'added_on': date_added.astimezone(pytz.utc).timestamp()})})
        rpc_client.torrents_info.return_value = [torrent_info]

        torrent = plugin.find_torrent(torrent_hash)

        self.assertEqual({'name': 'Torrent 1', 'date_added': date_added.astimezone(pytz.utc)}, torrent)

        rpc_client.torrents_info.assert_called_once_with(hashes=[torrent_hash.lower()])