Add a test for CloudStack compute driver which verifies that driver throws an exception if user instantiates the driver correctly, but doesn't provider host and path argument.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/0bdaad00 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/0bdaad00 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/0bdaad00 Branch: refs/heads/0.13.2 Commit: 0bdaad00cd31dcfac0dbc906c6ca6e93a28792bd Parents: d84dead Author: Tomaz Muraus <[email protected]> Authored: Sat Aug 17 16:45:55 2013 +0200 Committer: Tomaz Muraus <[email protected]> Committed: Fri Sep 13 15:15:24 2013 +0200 ---------------------------------------------------------------------- libcloud/test/compute/test_cloudstack.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/0bdaad00/libcloud/test/compute/test_cloudstack.py ---------------------------------------------------------------------- diff --git a/libcloud/test/compute/test_cloudstack.py b/libcloud/test/compute/test_cloudstack.py index 31562ff..2f27539 100644 --- a/libcloud/test/compute/test_cloudstack.py +++ b/libcloud/test/compute/test_cloudstack.py @@ -27,7 +27,8 @@ except ImportError: import json from libcloud.compute.drivers.cloudstack import CloudStackNodeDriver -from libcloud.compute.types import DeploymentError, LibcloudError +from libcloud.compute.types import DeploymentError, LibcloudError, Provider +from libcloud.compute.providers import get_driver from libcloud.compute.base import Node, NodeImage, NodeSize, NodeLocation from libcloud.test import unittest @@ -48,6 +49,19 @@ class CloudStackNodeDriverTest(unittest.TestCase, TestCaseMixin): CloudStackMockHttp.fixture_tag = 'default' self.driver.connection.poll_interval = 0.0 + def test_user_must_provide_host_and_path(self): + expected_msg = 'When instantiating CloudStack driver directly ' + \ + 'you also need to provide host and path argument' + cls = get_driver(Provider.CLOUDSTACK) + + self.assertRaisesRegexp(Exception, expected_msg, cls, + 'key', 'secret') + + try: + cls('key', 'secret', True, 'localhost', '/path') + except Exception: + self.fail('host and path provided but driver raised an exception') + def test_create_node_immediate_failure(self): size = self.driver.list_sizes()[0] image = self.driver.list_images()[0]
