Merge lp:~mwhudson/launchpad/fix-test_min_time_to_next_builder-non-utc-bug-525329 into lp:launchpad

Proposed by Michael Hudson-Doyle
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~mwhudson/launchpad/fix-test_min_time_to_next_builder-non-utc-bug-525329
Merge into: lp:launchpad
Diff against target: 30 lines (+3/-4)
1 file modified
lib/lp/buildmaster/tests/test_buildqueue.py (+3/-4)
To merge this branch: bzr merge lp:~mwhudson/launchpad/fix-test_min_time_to_next_builder-non-utc-bug-525329
Reviewer Review Type Date Requested Status
Māris Fogels (community) Approve
Paul Hummer (community) code Approve
Tim Penhey (community) Approve
Aaron Bentley (community) Approve
Review via email: mp+21082@code.launchpad.net

Commit message

test_min_time_to_next_builder fails in timezones ahead of UTC

Description of the change

As discussed in our standup.

To post a comment you must log in.
Revision history for this message
Aaron Bentley (abentley) :
review: Approve
Revision history for this message
Tim Penhey (thumper) :
review: Approve
Revision history for this message
Paul Hummer (rockstar) :
review: Approve (code)
Revision history for this message
Māris Fogels (mars) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/buildmaster/tests/test_buildqueue.py'
--- lib/lp/buildmaster/tests/test_buildqueue.py 2010-03-08 12:53:59 +0000
+++ lib/lp/buildmaster/tests/test_buildqueue.py 2010-03-10 21:05:38 +0000
@@ -96,8 +96,7 @@
96 queue_entry.lastscore)96 queue_entry.lastscore)
9797
9898
99def check_mintime_to_builder(99def check_mintime_to_builder(test, bq, min_time):
100 test, bq, min_time, time_stamp=datetime.utcnow()):
101 """Test the estimated time until a builder becomes available."""100 """Test the estimated time until a builder becomes available."""
102 # Monkey-patch BuildQueueSet._now() so it returns a constant time stamp101 # Monkey-patch BuildQueueSet._now() so it returns a constant time stamp
103 # that's not too far in the future. This avoids spurious test failures.102 # that's not too far in the future. This avoids spurious test failures.
@@ -113,7 +112,7 @@
113 """Set remaining running time for job."""112 """Set remaining running time for job."""
114 offset = bq.estimated_duration.seconds - remainder113 offset = bq.estimated_duration.seconds - remainder
115 bq.setDateStarted(114 bq.setDateStarted(
116 datetime.utcnow().replace(tzinfo=utc) - timedelta(seconds=offset))115 datetime.now(utc) - timedelta(seconds=offset))
117116
118117
119def check_delay_for_job(test, the_job, delay):118def check_delay_for_job(test, the_job, delay):
@@ -143,7 +142,7 @@
143 # Use the date/time the job started if available.142 # Use the date/time the job started if available.
144 time_stamp = buildqueue.job.date_started143 time_stamp = buildqueue.job.date_started
145 if not time_stamp:144 if not time_stamp:
146 time_stamp = datetime.utcnow()145 time_stamp = datetime.now(utc)
147 buildqueue._now = lambda: time_stamp146 buildqueue._now = lambda: time_stamp
148 return time_stamp147 return time_stamp
149148