def test_success(self):
        mock_communicator = mock.MagicMock(spec_set=NodeCommunicator)
        node = "node address"
        ca_cert = "CA certificate".encode("utf-8")

        lib.remote_client_setup(mock_communicator, node, ca_cert)

        mock_communicator.call_node.assert_called_once_with(
            node, "remote/qdevice_net_client_init_certificate_storage",
            "ca_certificate={0}".format(cert_to_url(ca_cert)))
    def test_success(self):
        mock_communicator = mock.MagicMock(spec_set=NodeCommunicator)
        node = "node address"
        ca_cert = "CA certificate".encode("utf-8")

        lib.remote_client_setup(mock_communicator, node, ca_cert)

        mock_communicator.call_node.assert_called_once_with(
            node,
            "remote/qdevice_net_client_init_certificate_storage",
            "ca_certificate={0}".format(
                cert_to_url(ca_cert)
            )
        )
    def test_comunication_error(self):
        mock_communicator = mock.MagicMock(spec_set=NodeCommunicator)
        mock_communicator.call_node.side_effect = NodeCommunicationException(
            "node address", "command", "reason")

        self.assertRaises(
            NodeCommunicationException, lambda: lib.remote_client_setup(
                mock_communicator, "node address", "ca cert".encode("utf-8")))
    def test_comunication_error(self):
        mock_communicator = mock.MagicMock(spec_set=NodeCommunicator)
        mock_communicator.call_node.side_effect = NodeCommunicationException(
            "node address", "command", "reason"
        )

        self.assertRaises(
            NodeCommunicationException,
            lambda: lib.remote_client_setup(
                mock_communicator,
                "node address",
                "ca cert".encode("utf-8")
            )
        )