def test_add_torrent_add_torrent_exception(self, transmission_client): rpc_client = transmission_client.return_value rpc_client.add_torrent.side_effect = transmissionrpc.TransmissionError plugin = TransmissionClientPlugin() settings = { 'host': 'localhost', 'username': '******', 'password': '******' } plugin.set_settings(settings) torrent = b'!torrent.content' with pytest.raises(transmissionrpc.TransmissionError) as e: plugin.add_torrent(torrent, None) rpc_client.add_torrent.assert_called_once_with( base64.b64encode(torrent).decode('utf-8'))
def test_add_torrent_without_credentials(self, transmission_client): rpc_client = transmission_client.return_value plugin = TransmissionClientPlugin() rpc_client.call.return_value = True torrent = b'!torrent.content' self.assertFalse(plugin.add_torrent(torrent, None)) rpc_client.add_torrent.assert_not_called()
def test_add_torrent_with_settings(self, transmission_client): rpc_client = transmission_client.return_value plugin = TransmissionClientPlugin() settings = {'host': 'localhost', 'username': '******', 'password': '******'} plugin.set_settings(settings) torrent = b'!torrent.content' self.assertTrue(plugin.add_torrent(torrent, TopicSettings('/path/to/download/dir'))) rpc_client.add_torrent.assert_called_once_with(base64.b64encode(torrent).decode('utf-8'), download_dir='/path/to/download/dir')
def test_add_torrent(self, transmission_client): rpc_client = transmission_client.return_value plugin = TransmissionClientPlugin() settings = {'host': 'localhost', 'username': '******', 'password': '******'} plugin.set_settings(settings) torrent = b'!torrent.content' self.assertTrue(plugin.add_torrent(torrent)) rpc_client.add_torrent.assert_called_once_with(base64.encodebytes(torrent))
def test_add_torrent(self, transmission_client): rpc_client = transmission_client.return_value plugin = TransmissionClientPlugin() settings = {'host': 'localhost', 'username': '******', 'password': '******'} plugin.set_settings(settings) torrent = b'!torrent.content' self.assertTrue(plugin.add_torrent(torrent)) rpc_client.add_torrent.assert_called_once_with(base64.encodestring(torrent))
def test_add_torrent_add_torrent_exception(self, transmission_client): rpc_client = transmission_client.return_value rpc_client.add_torrent.side_effect = transmissionrpc.TransmissionError plugin = TransmissionClientPlugin() settings = {'host': 'localhost', 'username': '******', 'password': '******'} plugin.set_settings(settings) torrent = b'!torrent.content' self.assertFalse(plugin.add_torrent(torrent, None)) rpc_client.add_torrent.assert_called_once_with(base64.b64encode(torrent).decode('utf-8'))
def test_add_torrent_with_settings(self, transmission_client): rpc_client = transmission_client.return_value plugin = TransmissionClientPlugin() settings = { 'host': 'localhost', 'username': '******', 'password': '******' } plugin.set_settings(settings) torrent = b'!torrent.content' self.assertTrue( plugin.add_torrent(torrent, TopicSettings('/path/to/download/dir'))) rpc_client.add_torrent.assert_called_once_with( base64.b64encode(torrent).decode('utf-8'), download_dir='/path/to/download/dir')