def test_find_torrent_connect_exception(self, deluge_client): rpc_client = deluge_client.return_value rpc_client.connected = True rpc_client.connect.side_effect = Exception plugin = DelugeClientPlugin() settings = { 'host': 'localhost', 'username': '******', 'password': '******' } plugin.set_settings(settings) torrent_hash = 'SomeRandomHashMockString' with pytest.raises(Exception) as e: plugin.find_torrent(torrent_hash) rpc_client.call.assert_not_called()
def test_find_torrent_without_credentials(self, deluge_client): rpc_client = deluge_client.return_value rpc_client.connected = True plugin = DelugeClientPlugin() torrent_hash = 'SomeRandomHashMockString' self.assertFalse(plugin.find_torrent(torrent_hash)) rpc_client.call.assert_not_called()
def test_find_torrent_false(self, deluge_client): rpc_client = deluge_client.return_value rpc_client.connected = True plugin = DelugeClientPlugin() settings = {"host": "localhost", "username": "******", "password": "******"} plugin.set_settings(settings) torrent_hash = "SomeRandomHashMockString" self.assertFalse(plugin.find_torrent(torrent_hash)) rpc_client.call.assert_called_once_with("core.get_torrent_status", torrent_hash.lower(), ["time_added", "name"])
def test_find_torrent_false(self, deluge_client): rpc_client = deluge_client.return_value rpc_client.connected = True plugin = DelugeClientPlugin() settings = {'host': 'localhost', 'username': '******', 'password': '******'} plugin.set_settings(settings) torrent_hash = 'SomeRandomHashMockString' self.assertFalse(plugin.find_torrent(torrent_hash)) rpc_client.call.assert_called_once_with('core.get_torrent_status', torrent_hash.lower(), ['time_added', 'name'])
def test_find_torrent_connect_exception(self, deluge_client): rpc_client = deluge_client.return_value rpc_client.connected = True rpc_client.connect.side_effect = Exception plugin = DelugeClientPlugin() settings = {'host': 'localhost', 'username': '******', 'password': '******'} plugin.set_settings(settings) torrent_hash = 'SomeRandomHashMockString' self.assertFalse(plugin.find_torrent(torrent_hash)) rpc_client.call.assert_not_called()
def test_find_torrent_connect_exception(self, deluge_client): rpc_client = deluge_client.return_value rpc_client.connected = True rpc_client.connect.side_effect = Exception plugin = DelugeClientPlugin() settings = {"host": "localhost", "username": "******", "password": "******"} plugin.set_settings(settings) torrent_hash = "SomeRandomHashMockString" self.assertFalse(plugin.find_torrent(torrent_hash)) rpc_client.call.assert_not_called()
def test_find_torrent(self, deluge_client): rpc_client = deluge_client.return_value rpc_client.connected = True plugin = DelugeClientPlugin() settings = {"host": "localhost", "username": "******", "password": "******"} plugin.set_settings(settings) date_added = datetime(2015, 10, 9, 12, 3, 55, tzinfo=pytz.reference.LocalTimezone()) rpc_client.call.return_value = {"name": "Torrent 1", "time_added": time.mktime(date_added.timetuple())} torrent_hash = "SomeRandomHashMockString" torrent = plugin.find_torrent(torrent_hash) self.assertEqual({"name": "Torrent 1", "date_added": date_added.astimezone(pytz.utc)}, torrent) rpc_client.call.assert_called_once_with("core.get_torrent_status", torrent_hash.lower(), ["time_added", "name"])
def test_find_torrent(self, deluge_client): rpc_client = deluge_client.return_value rpc_client.connected = True plugin = DelugeClientPlugin() settings = {'host': 'localhost', 'username': '******', 'password': '******'} plugin.set_settings(settings) date_added = datetime(2015, 10, 9, 12, 3, 55, tzinfo=pytz.reference.LocalTimezone()) rpc_client.call.return_value = {'name': 'Torrent 1', 'time_added': time.mktime(date_added.timetuple())} torrent_hash = 'SomeRandomHashMockString' torrent = plugin.find_torrent(torrent_hash) self.assertEqual({'name': 'Torrent 1', 'date_added': date_added.astimezone(pytz.utc)}, torrent) rpc_client.call.assert_called_once_with('core.get_torrent_status', torrent_hash.lower(), ['time_added', 'name'])