예제 #1
0
    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()
예제 #2
0
    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()
예제 #3
0
    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()
예제 #4
0
    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"])
예제 #5
0
    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'])
예제 #6
0
    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()
예제 #7
0
    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'])
예제 #8
0
    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()
예제 #9
0
    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"])
예제 #10
0
    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'])
예제 #11
0
    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'])