launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #22598
[Merge] lp:~cjwatson/launchpad/bugzilla-time-fields into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/bugzilla-time-fields into lp:launchpad.
Commit message:
Handle Bugzilla.time() changes in Bugzilla 5.1.1.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1774838 in Launchpad itself: "Launchpad issue watching bugs from the Linux Kernel Bug Tracker"
https://bugs.launchpad.net/launchpad/+bug/1774838
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/bugzilla-time-fields/+merge/347333
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/bugzilla-time-fields into lp:launchpad.
=== modified file 'lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt'
--- lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt 2017-10-24 17:50:22 +0000
+++ lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt 2018-06-03 08:36:54 +0000
@@ -123,6 +123,14 @@
CALLED Bugzilla.time()
datetime.datetime(2009, 8, 19, 22, 2, 2, tzinfo=<UTC>)
+Bugzilla >= 3.6 guarantees that db_time and web_time are in UTC, and
+Bugzilla >= 5.1.1 drops the web_time_utc flag. We can cope with that.
+
+ >>> test_transport.include_utc_time_fields = False
+ >>> bugzilla.getCurrentDBTime()
+ CALLED Bugzilla.time()
+ datetime.datetime(2009, 8, 19, 22, 2, 2, tzinfo=<UTC>)
+
Initializing the bug database
-----------------------------
=== modified file 'lib/lp/bugs/externalbugtracker/bugzilla.py'
--- lib/lp/bugs/externalbugtracker/bugzilla.py 2017-10-24 17:50:22 +0000
+++ lib/lp/bugs/externalbugtracker/bugzilla.py 2018-06-03 08:36:54 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2017 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Bugzilla ExternalBugTracker utility."""
@@ -654,11 +654,18 @@
# is sane, we work out the server's offset from UTC by looking
# at the difference between the web_time and the web_time_utc
# values.
- server_web_datetime = time_dict['web_time']
- server_web_datetime_utc = time_dict['web_time_utc']
- server_utc_offset = server_web_datetime - server_web_datetime_utc
- server_db_datetime = time_dict['db_time']
- server_utc_datetime = server_db_datetime - server_utc_offset
+ if 'web_time_utc' in time_dict:
+ # Bugzilla < 5.1.1 (although as of 3.6 the UTC offset is always
+ # 0).
+ server_web_datetime = time_dict['web_time']
+ server_web_datetime_utc = time_dict['web_time_utc']
+ server_utc_offset = server_web_datetime - server_web_datetime_utc
+ server_db_datetime = time_dict['db_time']
+ server_utc_datetime = server_db_datetime - server_utc_offset
+ else:
+ # Bugzilla >= 5.1.1. Times are always in UTC, so we can just
+ # use db_time directly.
+ server_utc_datetime = time_dict['db_time']
return server_utc_datetime.replace(tzinfo=pytz.timezone('UTC'))
def _getActualBugId(self, bug_id):
=== modified file 'lib/lp/bugs/tests/externalbugtracker.py'
--- lib/lp/bugs/tests/externalbugtracker.py 2017-10-20 11:07:01 +0000
+++ lib/lp/bugs/tests/externalbugtracker.py 2018-06-03 08:36:54 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2017 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Helper classes for testing ExternalSystem."""
@@ -871,6 +871,8 @@
},
}
+ include_utc_time_fields = True
+
def __init__(self, *args, **kwargs):
"""Ensure mutable class data is copied to the instance."""
TestBugzillaXMLRPCTransport.__init__(self, *args, **kwargs)
@@ -903,17 +905,26 @@
# data. We do this the old fashioned way because XML-RPC
# Transports don't support new-style classes.
time_dict = TestBugzillaXMLRPCTransport.time(self)
- offset_hours = (self.utc_offset / 60) / 60
- offset_string = '+%02d00' % offset_hours
- return {
- 'db_time': time_dict['local_time'],
- 'tz_name': time_dict['tz_name'],
- 'tz_offset': offset_string,
- 'tz_short_name': time_dict['tz_name'],
- 'web_time': time_dict['local_time'],
- 'web_time_utc': time_dict['utc_time'],
- }
+ if self.include_utc_time_fields:
+ # Bugzilla < 5.1.1 (although as of 3.6 the UTC offset is always
+ # 0).
+ offset_hours = (self.utc_offset / 60) / 60
+ offset_string = '+%02d00' % offset_hours
+ return {
+ 'db_time': time_dict['local_time'],
+ 'tz_name': time_dict['tz_name'],
+ 'tz_offset': offset_string,
+ 'tz_short_name': time_dict['tz_name'],
+ 'web_time': time_dict['local_time'],
+ 'web_time_utc': time_dict['utc_time'],
+ }
+ else:
+ # Bugzilla >= 5.1.1.
+ return {
+ 'db_time': time_dict['utc_time'],
+ 'web_time': time_dict['utc_time'],
+ }
def get(self, arguments):
"""Return a list of bug dicts for a given set of bug ids."""
Follow ups