Consistently use UTC timestamps in fake_gitlab

This is necessary to ensure that comparisons for updates to merge
requests function properly. Otherwise depending on your timezone you
could end up with an updated_at timestamp that is older than the
created_at timestamp preventing actions for updates from happening.

In particular this was breaking the
test_merge_request_updated_builds_aborted test for those of us running
the unittests on systems without UTC clocks.

Change-Id: I133bedf5dabe0f18e30598c3eb394c0a12b0ee0a
This commit is contained in:
Clark Boylan 2021-06-04 08:50:44 -07:00
parent 85e69c8eb0
commit b1c56c6cc9
1 changed files with 2 additions and 2 deletions

View File

@ -2102,7 +2102,7 @@ class FakeGitlabMergeRequest(object):
self.notes.append(
{
"body": body,
"created_at": datetime.datetime.now(),
"created_at": datetime.datetime.now(datetime.timezone.utc),
}
)
@ -2156,7 +2156,7 @@ class FakeGitlabMergeRequest(object):
repo.heads['master'].checkout()
def _updateTimeStamp(self):
self.updated_at = datetime.datetime.now()
self.updated_at = datetime.datetime.now(datetime.timezone.utc)
def getMergeRequestEvent(self, action, include_labels=False):
name = 'gl_merge_request'