libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject [libcloud] 03/05: Add test cases for it, update docstring.
Date Sun, 04 Oct 2020 17:09:04 GMT
This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git

commit 0eb48647e520ed61fa5f473f3b540be9885c3861
Author: Tomaz Muraus <tomaz@tomaz.me>
AuthorDate: Sun Oct 4 19:02:00 2020 +0200

    Add test cases for it, update docstring.
---
 libcloud/compute/drivers/gce.py   |  5 ++++-
 libcloud/test/compute/test_gce.py | 12 ++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/libcloud/compute/drivers/gce.py b/libcloud/compute/drivers/gce.py
index 51b7a35..414cf75 100644
--- a/libcloud/compute/drivers/gce.py
+++ b/libcloud/compute/drivers/gce.py
@@ -4887,7 +4887,10 @@ class GCENodeDriver(NodeDriver):
                                        accepts the aliases defined in
                                        'gcloud compute'.
 
-        :type     service_accounts: ``list`` of ``dict`` or None
+        :type     service_accounts: ``list`` of ``dict``, ``None`` or an empty
+                                    list. ``None` means use a default service
+                                    account and an empty list indicates no
+                                    service account.
 
         :return:  list of dictionaries usable in the GCE API.
         :rtype:   ``list`` of ``dict``
diff --git a/libcloud/test/compute/test_gce.py b/libcloud/test/compute/test_gce.py
index 4884729..b740870 100644
--- a/libcloud/test/compute/test_gce.py
+++ b/libcloud/test/compute/test_gce.py
@@ -63,6 +63,18 @@ class GCENodeDriverTest(GoogleTestCase, TestCaseMixin):
     def test_default_scopes(self):
         self.assertIsNone(self.driver.scopes)
 
+    def test_default_service_account(self):
+        result = self.driver._build_service_accounts_gce_list(service_accounts=None)
+        self.assertEqual(result, [
+            {'email': 'default',
+             'scopes': ['https://www.googleapis.com/auth/devstorage.read_only']
+             }
+        ])
+
+    def test_no_service_account(self):
+        result = self.driver._build_service_accounts_gce_list(service_accounts=[])
+        self.assertEqual(result, [])
+
     def test_timestamp_to_datetime(self):
         timestamp1 = '2013-06-26T10:05:19.340-07:00'
         datetime1 = datetime.datetime(2013, 6, 26, 17, 5, 19)


Mime
View raw message