class ElasticHostsTestCase(unittest.TestCase, TestCaseMixin):
    def setUp(self):
        ElasticHostsBaseNodeDriver.connectionCls.conn_classes = (None,
                                                            ElasticHostsHttp)
        self.driver = ElasticHostsBaseNodeDriver('foo', 'bar')

    def test_list_nodes(self):
        nodes = self.driver.list_nodes()
        self.assertTrue(isinstance(nodes, list))
        self.assertEqual(len(nodes), 1)
        
        node = nodes[0]
        self.assertEqual(node.public_ip[0], "1.2.3.4")
        self.assertEqual(node.public_ip[1], "1.2.3.5")
        self.assertEqual(node.extra['smp'], 1)

    def test_list_sizes(self):
        images = self.driver.list_sizes()
        self.assertEqual(len(images), 5)
        image = images[0]
        self.assertEqual(image.id, 'small')
        self.assertEqual(image.name, 'Small instance')
        self.assertEqual(image.cpu, 2000)
        self.assertEqual(image.ram, 1700)
        self.assertEqual(image.disk, 160)

    def test_list_images(self):
        sizes = self.driver.list_images()
        self.assertEqual(len(sizes), 9)
        size = sizes[0]
        self.assertEqual(size.id, '757586d5-f1e9-4d9c-b215-5a391c9a24bf')
        self.assertEqual(size.name, 'Ubuntu Linux 9.04: Base system with X')
        
    def test_list_locations_response(self):
        pass

    def test_reboot_node(self):
        node = self.driver.list_nodes()[0]
        self.assertTrue(self.driver.reboot_node(node))

    def test_destroy_node(self):
        node = self.driver.list_nodes()[0]
        self.assertTrue(self.driver.destroy_node(node))

    def test_create_node(self):
        size = self.driver.list_sizes()[0]
        image = self.driver.list_images()[0]
        self.assertTrue(self.driver.create_node(name="api.ivan.net.nz", image=image, size=size))
 def setUp(self):
     ElasticHostsBaseNodeDriver.connectionCls.conn_classes = (None,
                                                         ElasticHostsHttp)
     self.driver = ElasticHostsBaseNodeDriver('foo', 'bar')