You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2013/10/17 22:10:48 UTC

[12/16] git commit: Add tests for the new region functionality in the ElasticHosts driver.

Add tests for the new region functionality in the ElasticHosts driver.


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/bba0c2c9
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/bba0c2c9
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/bba0c2c9

Branch: refs/heads/trunk
Commit: bba0c2c92f6dab7024f37c62a3db6fae019e0f30
Parents: e3e1713
Author: Tomaz Muraus <to...@apache.org>
Authored: Thu Oct 17 21:09:27 2013 +0200
Committer: Tomaz Muraus <to...@apache.org>
Committed: Thu Oct 17 21:09:27 2013 +0200

----------------------------------------------------------------------
 libcloud/test/compute/test_elasticstack.py | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/bba0c2c9/libcloud/test/compute/test_elasticstack.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_elasticstack.py b/libcloud/test/compute/test_elasticstack.py
index 71577d1..fa9a387 100644
--- a/libcloud/test/compute/test_elasticstack.py
+++ b/libcloud/test/compute/test_elasticstack.py
@@ -152,6 +152,25 @@ class ElasticHostsTestCase(ElasticStackTestCase, unittest.TestCase):
                       i.id == '38df0986-4d85-4b76-b502-3878ffc80161'][0]
         super(ElasticHostsTestCase, self).setUp()
 
+    def test_multiple_drivers_with_different_regions(self):
+        driver1 = ElasticHosts('foo', 'bar', region='lon-p')
+        driver2 = ElasticHosts('foo', 'bar', region='sat-p')
+
+        self.assertTrue(driver1.connection.host.startswith('api-lon-p'))
+        self.assertTrue(driver2.connection.host.startswith('api-sat-p'))
+
+        driver1.list_nodes()
+        driver2.list_nodes()
+        driver1.list_nodes()
+
+        self.assertTrue(driver1.connection.host.startswith('api-lon-p'))
+        self.assertTrue(driver2.connection.host.startswith('api-sat-p'))
+
+    def test_invalid_region(self):
+        expected_msg = r'Invalid region.+'
+        self.assertRaisesRegexp(ValueError, expected_msg, ElasticHosts,
+                                'foo', 'bar', region='invalid')
+
 
 class SkaliCloudTestCase(ElasticStackTestCase, unittest.TestCase):