def test_remove_torrent_failed(self, get_mock):
        response = Response()
        response._content = b"<html><div id=''token'' style=''display:none;''>FKWBGjUDYXGNX7I-UBo5-UiWK1MUOaDmjjrorxOTzmEq3b0lWpr4no8v-FYAAAAA</div></html>"
        response.status_code = 200

        get_mock.side_effect = [response, Exception('boom')]

        plugin = UTorrentClientPlugin()
        settings = {'host': self.real_host, 'port': self.real_port, 'username': self.real_login,
                    'password': self.real_password}
        plugin.set_settings(settings)

        torrent = b'torrent'
        with pytest.raises(Exception) as e:
            plugin.remove_torrent(torrent)
    def test_remove_torrent_failed(self, get_mock):
        response = Response()
        response._content = b"<html><div id=''token'' style=''display:none;''>FKWBGjUDYXGNX7I-UBo5-UiWK1MUOaDmjjrorxOTzmEq3b0lWpr4no8v-FYAAAAA</div></html>"
        response.status_code = 200

        get_mock.side_effect = [response, Exception('boom')]

        plugin = UTorrentClientPlugin()
        settings = {'host': self.real_host, 'port': self.real_port, 'username': self.real_login,
                    'password': self.real_password}
        plugin.set_settings(settings)

        torrent = b'torrent'
        self.assertFalse(plugin.remove_torrent(torrent))
    def test_remove_torrent_success(self, get_mock):
        response = Response()
        response._content = b"<html><div id=''token'' style=''display:none;''>FKWBGjUDYXGNX7I-UBo5-UiWK1MUOaDmjjrorxOTzmEq3b0lWpr4no8v-FYAAAAA</div></html>"
        response.status_code = 200
        good_response = Response()
        good_response.status_code = 200
        get_mock.side_effect = [response, good_response]

        plugin = UTorrentClientPlugin()
        settings = {'host': self.real_host, 'port': self.real_port, 'username': self.real_login,
                    'password': self.real_password}
        plugin.set_settings(settings)

        torrent = b'torrent'
        self.assertTrue(plugin.remove_torrent(torrent))
Exemple #4
0
 def test_remove_torrent_bad_settings(self, get_mock):
     plugin = UTorrentClientPlugin()
     torrent = b'torrent'
     self.assertFalse(plugin.remove_torrent(torrent))
 def test_remove_torrent_bad_settings(self, get_mock):
     plugin = UTorrentClientPlugin()
     torrent = b'torrent'
     self.assertFalse(plugin.remove_torrent(torrent))