Exemplo n.º 1
0
 def setUp(self):
     LinodeNodeDriver.connectionCls.conn_classes = (None, LinodeMockHttp)
     LinodeMockHttp.use_param = 'api_action'
     self.driver = LinodeNodeDriver('foo')
Exemplo n.º 2
0
class LinodeTest(unittest.TestCase, TestCaseMixin):
    # The Linode test suite

    def setUp(self):
        LinodeNodeDriver.connectionCls.conn_classes = (None, LinodeMockHttp)
        LinodeMockHttp.use_param = "api_action"
        self.driver = LinodeNodeDriver("foo")

    def test_list_nodes(self):
        nodes = self.driver.list_nodes()
        self.assertEqual(len(nodes), 1)
        node = nodes[0]
        self.assertEqual(node.id, 8098)
        self.assertEqual(node.name, "api-node3")
        self.assertEqual(node.public_ip, "75.127.96.245")
        self.assertEqual(node.private_ip, None)

    def test_reboot_node(self):
        # An exception would indicate failure
        node = self.driver.list_nodes()[0]
        self.driver.reboot_node(node)

    def test_destroy_node(self):
        # An exception would indicate failure
        node = self.driver.list_nodes()[0]
        self.driver.destroy_node(node)

    def test_create_node(self):
        # Will exception on failure
        size = self.driver.list_sizes()[0]
        distro = self.driver.list_images()[6]
        self.driver.linode_set_datacenter(2)
        node = self.driver.create_node("Test", distro, size, root="test123")

    def test_list_sizes(self):
        sizes = self.driver.list_sizes()
        self.assertEqual(len(sizes), 10)
        for size in sizes:
            self.assertEqual(size.ram, int(size.name.split(" ")[1]))

    def test_list_images(self):
        images = self.driver.list_images()
        self.assertEqual(len(images), 22)

    def test_create_node_response(self):
        # should return a node object
        size = self.driver.list_sizes()[0]
        image = self.driver.list_images()[0]
        kwargs = {"root": "foobar"}
        node = self.driver.create_node("node-name", image, size, **kwargs)
        self.assertTrue(isinstance(node, Node))
Exemplo n.º 3
0
class LinodeTest(unittest.TestCase, TestCaseMixin):
    # The Linode test suite

    def setUp(self):
        LinodeNodeDriver.connectionCls.conn_classes = (None, LinodeMockHttp)
        LinodeMockHttp.use_param = 'api_action'
        self.driver = LinodeNodeDriver('foo')

    def test_list_nodes(self):
        nodes = self.driver.list_nodes()
        self.assertEqual(len(nodes), 1)
        node = nodes[0]
        self.assertEqual(node.id, "8098")
        self.assertEqual(node.name, 'api-node3')
        self.assertTrue('75.127.96.245' in node.public_ip)
        self.assertEqual(node.private_ip, [])

    def test_reboot_node(self):
        # An exception would indicate failure
        node = self.driver.list_nodes()[0]
        self.driver.reboot_node(node)

    def test_destroy_node(self):
        # An exception would indicate failure
        node = self.driver.list_nodes()[0]
        self.driver.destroy_node(node)

    def test_create_node(self):
        # Will exception on failure
        self.driver.create_node(name="Test",
                                location=self.driver.list_locations()[0],
                                size=self.driver.list_sizes()[0],
                                image=self.driver.list_images()[6],
                                auth=NodeAuthPassword("test123"))

    def test_list_sizes(self):
        sizes = self.driver.list_sizes()
        self.assertEqual(len(sizes), 10)
        for size in sizes:
            self.assertEqual(size.ram, int(size.name.split(" ")[1]))

    def test_list_images(self):
        images = self.driver.list_images()
        self.assertEqual(len(images), 22)

    def test_create_node_response(self):
        # should return a node object
        node = self.driver.create_node(name="node-name",
                         location=self.driver.list_locations()[0],
                         size=self.driver.list_sizes()[0],
                         image=self.driver.list_images()[0],
                         auth=NodeAuthPassword("foobar"))
        self.assertTrue(isinstance(node[0], Node))
Exemplo n.º 4
0
class LinodeTest(unittest.TestCase):
    # The Linode test suite
    
    def setUp(self):
        LinodeNodeDriver.connectionCls.conn_classes = (None, LinodeMockHttp)
        LinodeMockHttp.use_param = 'api_action'
        self.driver = LinodeNodeDriver('foo')

    def test_list_nodes(self):
        nodes = self.driver.list_nodes()
        self.assertEqual(len(nodes), 1)
        node = nodes[0]
        self.assertEqual(node.id, 8098)
        self.assertEqual(node.name, 'api-node3')
        self.assertEqual(node.public_ip, '75.127.96.245')
        self.assertEqual(node.private_ip, None)
    
    def test_reboot_node(self):
        # An exception would indicate failure
        node = self.driver.list_nodes()[0]
        self.driver.reboot_node(node)

    def test_destroy_node(self):
        # An exception would indicate failure
        node = self.driver.list_nodes()[0]
        self.driver.destroy_node(node)
    
    def test_create_node(self):
        # Will exception on failure
        size = self.driver.list_sizes()[0]
        distro = self.driver.list_images()[6]
        self.driver.linode_set_datacenter(2)
        node = self.driver.create_node("Test", distro, size, root="test123")
    
    def test_list_sizes(self):
        sizes = self.driver.list_sizes()
        self.assertEqual(len(sizes), 10)
        for size in sizes:
            self.assertEqual(size.ram, int(size.name.split(" ")[1]))
    
    def test_list_images(self):
        images = self.driver.list_images()
        self.assertEqual(len(images), 22)