Пример #1
0
    def test_settings(self):
        plugin = DelugeClientPlugin()
        settings = {'host': 'localhost', 'username': '******', 'password': '******'}
        self.assertIsNone(plugin.get_settings())
        plugin.set_settings(settings)
        readed_settings = plugin.get_settings()

        self.assertEqual({'host': 'localhost', 'port': None, 'username': '******'}, readed_settings)
Пример #2
0
    def test_settings(self):
        plugin = DelugeClientPlugin()
        settings = {"host": "localhost", "username": "******", "password": "******"}
        self.assertIsNone(plugin.get_settings())
        plugin.set_settings(settings)
        readed_settings = plugin.get_settings()

        self.assertEqual({"host": "localhost", "port": None, "username": "******"}, readed_settings)
Пример #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_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()
Пример #5
0
    def test_get_download_dir_exception(self, deluge_client):
        rpc_client = deluge_client.return_value
        rpc_client.connected = True
        rpc_client.call.side_effect = Exception

        plugin = DelugeClientPlugin()
        settings = {'host': 'localhost', 'username': '******', 'password': '******'}
        plugin.set_settings(settings)

        assert plugin.get_download_dir() is None

        rpc_client.call.assert_called_once_with('core.get_config_value', 'download_location')
Пример #6
0
    def test_add_torrent_without_credentials(self, deluge_client):
        rpc_client = deluge_client.return_value
        rpc_client.connected = True

        plugin = DelugeClientPlugin()

        rpc_client.call.return_value = True

        torrent = b'!torrent.content'
        self.assertFalse(plugin.add_torrent(torrent))

        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_check_connection_failed(self, deluge_client):
        rpc_client = deluge_client.return_value
        rpc_client.connected = True

        plugin = DelugeClientPlugin()

        self.assertFalse(plugin.check_connection())

        deluge_client.assert_not_called()

        connect_mock = rpc_client.connect
        connect_mock.assert_not_called()
Пример #9
0
    def test_add_torrent_without_credentials(self, deluge_client):
        rpc_client = deluge_client.return_value
        rpc_client.connected = True

        plugin = DelugeClientPlugin()

        rpc_client.call.return_value = True

        torrent = b'!torrent.content'
        self.assertFalse(plugin.add_torrent(torrent))

        rpc_client.call.assert_not_called()
Пример #10
0
    def test_check_connection_failed(self, deluge_client):
        rpc_client = deluge_client.return_value
        rpc_client.connected = True

        plugin = DelugeClientPlugin()

        self.assertFalse(plugin.check_connection())

        deluge_client.assert_not_called()

        connect_mock = rpc_client.connect
        connect_mock.assert_not_called()
Пример #11
0
    def test_add_torrent_call_exception(self, deluge_client):
        rpc_client = deluge_client.return_value
        rpc_client.connected = True
        rpc_client.call.side_effect = Exception

        plugin = DelugeClientPlugin()
        settings = {'host': 'localhost', 'username': '******', 'password': '******'}
        plugin.set_settings(settings)

        torrent = b'!torrent.content'
        self.assertFalse(plugin.add_torrent(torrent, None))

        rpc_client.call.assert_called_once_with('core.add_torrent_file', None, base64.b64encode(torrent), None)
Пример #12
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'])
Пример #13
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()
Пример #14
0
    def test_remove_torrent_call_exception(self, deluge_client):
        rpc_client = deluge_client.return_value
        rpc_client.connected = True
        rpc_client.call.side_effect = Exception

        plugin = DelugeClientPlugin()
        settings = {'host': 'localhost', 'username': '******', 'password': '******'}
        plugin.set_settings(settings)

        torrent_hash = 'SomeRandomHashMockString'
        self.assertFalse(plugin.remove_torrent(torrent_hash))

        rpc_client.call.assert_called_once_with('core.remove_torrent', torrent_hash.lower(), False)
Пример #15
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()
Пример #16
0
    def test_remove_torrent_call_exception(self, deluge_client):
        rpc_client = deluge_client.return_value
        rpc_client.connected = True
        rpc_client.call.side_effect = Exception

        plugin = DelugeClientPlugin()
        settings = {"host": "localhost", "username": "******", "password": "******"}
        plugin.set_settings(settings)

        torrent_hash = "SomeRandomHashMockString"
        self.assertFalse(plugin.remove_torrent(torrent_hash))

        rpc_client.call.assert_called_once_with("core.remove_torrent", torrent_hash.lower(), False)
Пример #17
0
    def test_add_torrent_call_exception(self, deluge_client):
        rpc_client = deluge_client.return_value
        rpc_client.connected = True
        rpc_client.call.side_effect = Exception

        plugin = DelugeClientPlugin()
        settings = {'host': 'localhost', 'username': '******', 'password': '******'}
        plugin.set_settings(settings)

        torrent = b'!torrent.content'
        self.assertFalse(plugin.add_torrent(torrent))

        rpc_client.call.assert_called_once_with('core.add_torrent_file', None, base64.encodestring(torrent), None)
Пример #18
0
    def test_remove_torrent_call_exception(self, deluge_client):
        rpc_client = deluge_client.return_value
        rpc_client.connected = True
        rpc_client.call.side_effect = Exception

        plugin = DelugeClientPlugin()
        settings = {'host': 'localhost', 'username': '******', 'password': '******'}
        plugin.set_settings(settings)

        torrent_hash = 'SomeRandomHashMockString'
        self.assertFalse(plugin.remove_torrent(torrent_hash))

        rpc_client.call.assert_called_once_with('core.remove_torrent', torrent_hash.lower(), False)
Пример #19
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()
Пример #20
0
    def test_add_torrent_call_exception(self, deluge_client):
        rpc_client = deluge_client.return_value
        rpc_client.connected = True
        rpc_client.call.side_effect = Exception

        plugin = DelugeClientPlugin()
        settings = {"host": "localhost", "username": "******", "password": "******"}
        plugin.set_settings(settings)

        torrent = b"!torrent.content"
        self.assertFalse(plugin.add_torrent(torrent, None))

        rpc_client.call.assert_called_once_with("core.add_torrent_file", None, base64.b64encode(torrent), None)
Пример #21
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'])
Пример #22
0
    def test_check_connection_successfull(self, value, deluge_client):
        rpc_client = deluge_client.return_value
        rpc_client.connected = value

        plugin = DelugeClientPlugin()
        settings = {'host': 'localhost', 'username': '******', 'password': '******'}
        plugin.set_settings(settings)

        self.assertEqual(value, plugin.check_connection())

        deluge_client.assert_called_with('localhost', DelugeClientPlugin.DEFAULT_PORT, 'monitorrent', 'monitorrent')

        connect_mock = rpc_client.connect
        connect_mock.assert_called_once_with()
Пример #23
0
    def test_add_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)

        rpc_client.call.return_value = True

        torrent = b'!torrent.content'
        self.assertTrue(plugin.add_torrent(torrent))

        rpc_client.call.assert_called_once_with('core.add_torrent_file', None, base64.encodebytes(torrent), None)
Пример #24
0
    def test_check_connection_connect_exception(self, deluge_client):
        rpc_client = deluge_client.return_value
        rpc_client.connect.side_effect = Exception

        plugin = DelugeClientPlugin()
        settings = {"host": "localhost", "username": "******", "password": "******"}
        plugin.set_settings(settings)

        self.assertFalse(plugin.check_connection())

        deluge_client.assert_called_with("localhost", DelugeClientPlugin.DEFAULT_PORT, "monitorrent", "monitorrent")

        connect_mock = rpc_client.connect
        connect_mock.assert_called_once_with()
Пример #25
0
    def test_check_connection_connect_exception(self, deluge_client):
        rpc_client = deluge_client.return_value
        rpc_client.connect.side_effect = Exception

        plugin = DelugeClientPlugin()
        settings = {'host': 'localhost', 'username': '******', 'password': '******'}
        plugin.set_settings(settings)

        self.assertFalse(plugin.check_connection())

        deluge_client.assert_called_with('localhost', DelugeClientPlugin.DEFAULT_PORT, 'monitorrent', 'monitorrent')

        connect_mock = rpc_client.connect
        connect_mock.assert_called_once_with()
Пример #26
0
    def test_check_connection_successfull(self, value, deluge_client):
        rpc_client = deluge_client.return_value
        rpc_client.connected = value

        plugin = DelugeClientPlugin()
        settings = {"host": "localhost", "username": "******", "password": "******"}
        plugin.set_settings(settings)

        self.assertEqual(value, plugin.check_connection())

        deluge_client.assert_called_with("localhost", DelugeClientPlugin.DEFAULT_PORT, "monitorrent", "monitorrent")

        connect_mock = rpc_client.connect
        connect_mock.assert_called_once_with()
Пример #27
0
    def test_check_connection_connect_exception(self, deluge_client):
        rpc_client = deluge_client.return_value
        rpc_client.connect.side_effect = Exception

        plugin = DelugeClientPlugin()
        settings = {'host': 'localhost', 'username': '******', 'password': '******'}
        plugin.set_settings(settings)

        self.assertFalse(plugin.check_connection())

        deluge_client.assert_called_with('localhost', DelugeClientPlugin.DEFAULT_PORT, 'monitorrent', 'monitorrent')

        connect_mock = rpc_client.connect
        connect_mock.assert_called_once_with()
Пример #28
0
    def test_check_connection_successfull(self, value, deluge_client):
        rpc_client = deluge_client.return_value
        rpc_client.connected = value

        plugin = DelugeClientPlugin()
        settings = {'host': 'localhost', 'username': '******', 'password': '******'}
        plugin.set_settings(settings)

        self.assertEqual(value, plugin.check_connection())

        deluge_client.assert_called_with('localhost', DelugeClientPlugin.DEFAULT_PORT, 'monitorrent', 'monitorrent')

        connect_mock = rpc_client.connect
        connect_mock.assert_called_once_with()
Пример #29
0
    def test_add_torrent_with_settings(self, deluge_client):
        rpc_client = deluge_client.return_value
        rpc_client.connected = True

        plugin = DelugeClientPlugin()
        settings = {"host": "localhost", "username": "******", "password": "******"}
        plugin.set_settings(settings)

        rpc_client.call.return_value = True

        torrent = b"!torrent.content"
        self.assertTrue(plugin.add_torrent(torrent, TopicSettings("/path/to/download")))

        options = {"download_location": "/path/to/download"}

        rpc_client.call.assert_called_once_with("core.add_torrent_file", None, base64.b64encode(torrent), options)
Пример #30
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"])
Пример #31
0
    def test_add_torrent_with_settings(self, deluge_client):
        rpc_client = deluge_client.return_value
        rpc_client.connected = True

        plugin = DelugeClientPlugin()
        settings = {'host': 'localhost', 'username': '******', 'password': '******'}
        plugin.set_settings(settings)

        rpc_client.call.return_value = True

        torrent = b'!torrent.content'
        self.assertTrue(plugin.add_torrent(torrent, TopicSettings('/path/to/download')))

        options = {
            'download_location': '/path/to/download'
        }

        rpc_client.call.assert_called_once_with('core.add_torrent_file', None, base64.b64encode(torrent), options)
Пример #32
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'])
Пример #33
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'])
Пример #34
0
    def test_add_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)

        rpc_client.call.return_value = True

        torrent = b'!torrent.content'
        self.assertTrue(plugin.add_torrent(torrent))

        rpc_client.call.assert_called_once_with('core.add_torrent_file', None,
                                                base64.encodebytes(torrent),
                                                None)
Пример #35
0
    def test_settings(self):
        plugin = DelugeClientPlugin()
        settings = {'host': 'localhost', 'username': '******', 'password': '******'}
        self.assertIsNone(plugin.get_settings())
        plugin.set_settings(settings)
        readed_settings = plugin.get_settings()

        self.assertEqual({'host': 'localhost', 'port': None, 'username': '******'}, readed_settings)
Пример #36
0
    def test_get_download_dir_success(self, deluge_client):
        rpc_client = deluge_client.return_value
        rpc_client.connected = True
        rpc_client.call.return_value = b'/mnt/media/torrents/complete'

        plugin = DelugeClientPlugin()

        assert plugin.get_download_dir() is None

        settings = {'host': 'localhost', 'username': '******', 'password': '******'}
        plugin.set_settings(settings)

        assert plugin.get_download_dir() == u'/mnt/media/torrents/complete'

        rpc_client.call.assert_called_once_with('core.get_config_value', 'download_location')