libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject [libcloud] 01/02: Fix a bug with the header in the zone export file containing invalid timestamp.
Date Sun, 11 Oct 2020 10:55:42 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 021c144e6e3e2aff04fff0f6dbb4e2a272ed6b41
Author: Tomaz Muraus <tomaz@tomaz.me>
AuthorDate: Sun Oct 11 12:50:32 2020 +0200

    Fix a bug with the header in the zone export file containing invalid
    timestamp.
    
    Fixes #1500.
---
 libcloud/dns/base.py           |  2 +-
 libcloud/test/dns/test_base.py | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/libcloud/dns/base.py b/libcloud/dns/base.py
index 25384fd..a90f2e9 100644
--- a/libcloud/dns/base.py
+++ b/libcloud/dns/base.py
@@ -493,7 +493,7 @@ 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.now().strftime('%Y-%m-%d %H:%M:%S')
         values = {'version': __version__, 'date': date}
 
         lines.append('; Generated by Libcloud v%(version)s on %(date)s' %
diff --git a/libcloud/test/dns/test_base.py b/libcloud/test/dns/test_base.py
index 3472d5e..c1a8d27 100644
--- a/libcloud/test/dns/test_base.py
+++ b/libcloud/test/dns/test_base.py
@@ -16,9 +16,11 @@ from __future__ import with_statement
 
 import sys
 import tempfile
+import datetime
 
 from mock import Mock
 
+from libcloud import __version__
 from libcloud.test import unittest
 from libcloud.dns.base import DNSDriver, Zone, Record
 from libcloud.dns.types import RecordType
@@ -91,6 +93,14 @@ class BaseTestCase(unittest.TestCase):
         lines1 = result.split('\n')
         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)
+        expected_header = "; Generated by Libcloud v%s on %s" % (__version__, date_str)
+
+        self.assertEqual(lines1[0], expected_header)
+        self.assertEqual(lines2[0], expected_header)
+
         for lines in [lines1, lines2]:
             self.assertEqual(len(lines), 2 + 1 + 9)
             assertRegex(self, lines[1], r'\$ORIGIN example\.com\.')


Mime
View raw message