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 2020/10/11 16:04:57 UTC

[libcloud] branch trunk updated (403c6bf -> d5e957a)

This is an automated email from the ASF dual-hosted git repository.

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


    from 403c6bf  Add changelog entry.
     new f6d6e06  Fix failing test - make sure we correctly 0 pad all the values < 10.
     new d5e957a  Update header string in the BIND zone export content so it utilizes UTC instead of a local timestamp.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 libcloud/dns/base.py           |  4 ++--
 libcloud/test/dns/test_base.py | 18 ++++++++++++++----
 2 files changed, 16 insertions(+), 6 deletions(-)


[libcloud] 02/02: Update header string in the BIND zone export content so it utilizes UTC instead of a local timestamp.

Posted by to...@apache.org.
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 d5e957a1de40c216525fd0996ce04d74f3887886
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Sun Oct 11 15:35:53 2020 +0200

    Update header string in the BIND zone export content so it utilizes UTC
    instead of a local timestamp.
---
 libcloud/dns/base.py           | 4 ++--
 libcloud/test/dns/test_base.py | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libcloud/dns/base.py b/libcloud/dns/base.py
index a90f2e9..f6dad56 100644
--- a/libcloud/dns/base.py
+++ b/libcloud/dns/base.py
@@ -493,10 +493,10 @@ class DNSDriver(BaseDriver):
         records = zone.list_records()
         records = sorted(records, key=Record._get_numeric_id)
 
-        date = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
+        date = datetime.datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')
         values = {'version': __version__, 'date': date}
 
-        lines.append('; Generated by Libcloud v%(version)s on %(date)s' %
+        lines.append('; Generated by Libcloud v%(version)s on %(date)s UTC' %
                      values)
         lines.append('$ORIGIN %(domain)s.' % {'domain': zone.domain})
         lines.append('$TTL %(domain_ttl)s\n' % {'domain_ttl': zone.ttl})
diff --git a/libcloud/test/dns/test_base.py b/libcloud/test/dns/test_base.py
index 1ceba05..bb699f4 100644
--- a/libcloud/test/dns/test_base.py
+++ b/libcloud/test/dns/test_base.py
@@ -93,13 +93,13 @@ class BaseTestCase(unittest.TestCase):
         lines1 = result.split('\n')
         lines2 = content.split('\n')
 
-        now = datetime.datetime.now()
+        now = datetime.datetime.utcnow()
         date_str = "%s-%s-%s %s:%s:%s" % (now.year, zero_pad(now.month),
                                           zero_pad(now.day),
                                           zero_pad(now.hour),
                                           zero_pad(now.minute),
                                           zero_pad(now.second))
-        expected_header = "; Generated by Libcloud v%s on %s" % (__version__, date_str)
+        expected_header = "; Generated by Libcloud v%s on %s UTC" % (__version__, date_str)
 
         self.assertEqual(lines1[0], expected_header)
         self.assertEqual(lines2[0], expected_header)


[libcloud] 01/02: Fix failing test - make sure we correctly 0 pad all the values < 10.

Posted by to...@apache.org.
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 f6d6e0613539dd3a3b474a2c79675ba8a5071502
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Sun Oct 11 15:35:00 2020 +0200

    Fix failing test - make sure we correctly 0 pad all the values < 10.
---
 libcloud/test/dns/test_base.py | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/libcloud/test/dns/test_base.py b/libcloud/test/dns/test_base.py
index c1a8d27..1ceba05 100644
--- a/libcloud/test/dns/test_base.py
+++ b/libcloud/test/dns/test_base.py
@@ -94,8 +94,11 @@ class BaseTestCase(unittest.TestCase):
         lines2 = content.split('\n')
 
         now = datetime.datetime.now()
-        date_str = "%s-%s-%s %s:%s:%s" % (now.year, now.month, now.day, now.hour, now.minute,
-                                          now.second)
+        date_str = "%s-%s-%s %s:%s:%s" % (now.year, zero_pad(now.month),
+                                          zero_pad(now.day),
+                                          zero_pad(now.hour),
+                                          zero_pad(now.minute),
+                                          zero_pad(now.second))
         expected_header = "; Generated by Libcloud v%s on %s" % (__version__, date_str)
 
         self.assertEqual(lines1[0], expected_header)
@@ -142,5 +145,12 @@ class BaseTestCase(unittest.TestCase):
         self.assertEqual(result, '')
 
 
+def zero_pad(value: int) -> str:
+    if value < 10:
+        return "0" + str(value)
+
+    return str(value)
+
+
 if __name__ == '__main__':
     sys.exit(unittest.main())