Esempio n. 1
0
 def test_get_connection(self, mode, args, env, path, mc, ms):
     with mock.patch("os.environ", env):
         conn = connection.LXDConnection(*args).get_connection()
         if mode.startswith("unix"):
             self.assertEqual(mc.return_value, conn)
             mc.assert_called_once_with(path)
         elif mode.startswith("https"):
             self.assertEqual(ms.return_value, conn)
             ms.assert_called_once_with(args[0], len(args) == 2 and args[1] or 8443)
Esempio n. 2
0
 def __init__(self, host=None, port=8443):
     warnings.warn("pylxd.api.API is deprecated. Please use pylxd.Client.",
                   DeprecationWarning)
     conn = self.connection = connection.LXDConnection(host=host, port=port)
     self.hosts = hosts.LXDHost(conn)
     self.image = image.LXDImage(conn)
     self.alias = image.LXDAlias(conn)
     self.network = network.LXDNetwork(conn)
     self.operation = operation.LXDOperation(conn)
     self.profiles = profiles.LXDProfile(conn)
     self.certificate = certificate.LXDCertificate(conn)
     self.container = container.LXDContainer(conn)
Esempio n. 3
0
    def test_get_ws(self, host, result, mock_ws, _):
        conn = connection.LXDConnection(host)

        conn.get_ws('/fake/path')

        mock_ws.assert_has_calls([mock.call(result), mock.call().connect()])
Esempio n. 4
0
 def setUp(self):
     super(LXDConnectionTest, self).setUp()
     self.conn = connection.LXDConnection()
Esempio n. 5
0
 def setUp(self):
     super().setUp()
     self.conn = connection.LXDConnection()
Esempio n. 6
0
 def __init__(self, conn=None):
     self.connection = conn or connection.LXDConnection()