class GoGridTests(unittest.TestCase, TestCaseMixin): def setUp(self): GoGridNodeDriver.connectionCls.conn_classes = (None, GoGridMockHttp) GoGridMockHttp.type = None self.driver = GoGridNodeDriver("foo", "bar") def test_create_node(self): image = NodeImage(1531, None, self.driver) size = NodeSize('512Mb', None, None, None, None, None, driver=self.driver) node = self.driver.create_node(name='test1', image=image, size=size) self.assertEqual(node.name, 'test1') self.assertTrue(node.id is not None) self.assertEqual(node.extra['password'], 'bebebe') def test_list_nodes(self): node = self.driver.list_nodes()[0] self.assertEqual(node.id, '90967') self.assertEqual(node.extra['password'], 'bebebe') self.assertEqual(node.extra['isSandbox'], False) def test_reboot_node(self): node = Node(90967, None, None, None, None, self.driver) ret = self.driver.reboot_node(node) self.assertTrue(ret) def test_destroy_node(self): node = Node(90967, None, None, None, None, self.driver) ret = self.driver.destroy_node(node) self.assertTrue(ret) def test_list_images(self): images = self.driver.list_images() image = images[0] self.assertEqual(len(images), 4) self.assertEqual(image.name, 'CentOS 5.3 (32-bit) w/ None') self.assertEqual(image.id, '1531') def test_malformed_reply(self): GoGridMockHttp.type = 'FAIL' try: images = self.driver.list_images() except LibcloudError, e: self.assertTrue(isinstance(e, LibcloudError)) else:
def setUp(self): GoGridNodeDriver.connectionCls.conn_classes = (None, GoGridMockHttp) GoGridMockHttp.type = None self.driver = GoGridNodeDriver("foo", "bar")