libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From quent...@apache.org
Subject [5/6] libcloud git commit: Added test for ex_fetch_power_state=False
Date Fri, 13 Oct 2017 04:21:52 GMT
Added test for ex_fetch_power_state=False

Signed-off-by: Quentin Pradet <quentinp@apache.org>


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

Branch: refs/heads/trunk
Commit: cf71b555dc8c77f1396fd5e8c6eae5ff275769c7
Parents: 2a95669
Author: Lucas Di Pentima <ldipentima@veritasgenetics.com>
Authored: Thu Oct 12 17:04:29 2017 -0300
Committer: Quentin Pradet <quentinp@apache.org>
Committed: Fri Oct 13 08:16:29 2017 +0400

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


http://git-wip-us.apache.org/repos/asf/libcloud/blob/cf71b555/libcloud/test/compute/test_azure_arm.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_azure_arm.py b/libcloud/test/compute/test_azure_arm.py
index b4dd1fd..3367125 100644
--- a/libcloud/test/compute/test_azure_arm.py
+++ b/libcloud/test/compute/test_azure_arm.py
@@ -205,7 +205,9 @@ class AzureNodeDriverTests(LibcloudTestCase):
         with self.assertRaises(BaseHTTPError):
             self.driver.destroy_node(node)
 
-    def test_list_nodes(self):
+    @mock.patch('libcloud.compute.drivers.azure_arm.AzureNodeDriver'
+                '._fetch_power_state', return_value=NodeState.UPDATING)
+    def test_list_nodes(self, fps_mock):
         nodes = self.driver.list_nodes()
 
         self.assertEqual(len(nodes), 1)
@@ -215,6 +217,22 @@ class AzureNodeDriverTests(LibcloudTestCase):
         self.assertEqual(nodes[0].private_ips, ['10.0.0.1'])
         self.assertEqual(nodes[0].public_ips, [])
 
+        fps_mock.assert_called()
+
+    @mock.patch('libcloud.compute.drivers.azure_arm.AzureNodeDriver'
+                '._fetch_power_state', return_value=NodeState.UPDATING)
+    def test_list_nodes__no_fetch_power_state(self, fps_mock):
+        nodes = self.driver.list_nodes(ex_fetch_power_state=False)
+
+        self.assertEqual(len(nodes), 1)
+
+        self.assertEqual(nodes[0].name, 'test-node-1')
+        self.assertNotEqual(nodes[0].state, NodeState.UPDATING)
+        self.assertEqual(nodes[0].private_ips, ['10.0.0.1'])
+        self.assertEqual(nodes[0].public_ips, [])
+
+        fps_mock.assert_not_called()
+
     def test_create_volume(self):
         location = self.driver.list_locations()[-1]
         volume = self.driver.create_volume(


Mime
View raw message