# HG changeset patch # User domruf # Date 2017-08-08 21:35:20 # Node ID 71033bd37b4cc6e6e9c032fa1663c63024fe5cd7 # Parent d43cf470e625837f2776fbcff85629ffda1d62cd api: change precision of ChangesetStatus.modified_at to seconds Per default MySQL only uses seconds. So in order to be consistent on all databases, this is the easiest solution. I don't think the microseconds are necessary. And AFAICS mercurial only uses seconds for the changeset modification time as well. So why should we use microseconds for ChangesetStatus. Without this, for example test_api_get_changeset_with_reviews fails, because of datetime mismatch if MySQL is used. diff --git a/kallithea/model/db.py b/kallithea/model/db.py --- a/kallithea/model/db.py +++ b/kallithea/model/db.py @@ -2312,7 +2312,7 @@ class ChangesetStatus(Base, BaseDbModel) def __json__(self): return dict( status=self.status, - modified_at=self.modified_at, + modified_at=self.modified_at.replace(microsecond=0), reviewer=self.author.username, ) diff --git a/kallithea/tests/api/api_base.py b/kallithea/tests/api/api_base.py --- a/kallithea/tests/api/api_base.py +++ b/kallithea/tests/api/api_base.py @@ -2501,7 +2501,7 @@ class _BaseTestApi(object): review = result["reviews"][0] expected = { 'status': 'approved', - 'modified_at': reviewobjs[0].modified_at.isoformat()[:-3], + 'modified_at': reviewobjs[0].modified_at.replace(microsecond=0).isoformat(), 'reviewer': 'test_admin', } assert review == expected @@ -2550,13 +2550,13 @@ class _BaseTestApi(object): "comments": [{"username": TEST_USER_ADMIN_LOGIN, "text": "", "comment_id": pullrequest.comments[0].comment_id}], "owner": TEST_USER_ADMIN_LOGIN, - "statuses": [{"status": "under_review", "reviewer": TEST_USER_ADMIN_LOGIN, "modified_at": "2000-01-01T00:00:00.000"} for i in range(0, len(self.TEST_PR_REVISIONS))], + "statuses": [{"status": "under_review", "reviewer": TEST_USER_ADMIN_LOGIN, "modified_at": "2000-01-01T00:00:00"} for i in range(0, len(self.TEST_PR_REVISIONS))], "title": "get test", "revisions": self.TEST_PR_REVISIONS, } self._compare_ok(random_id, expected, - given=re.sub("\d\d\d\d\-\d\d\-\d\dT\d\d\:\d\d\:\d\d\.\d\d\d", - "2000-01-01T00:00:00.000", response.body)) + given=re.sub("\d\d\d\d\-\d\d\-\d\dT\d\d\:\d\d\:\d\d", + "2000-01-01T00:00:00", response.body)) def test_api_close_pullrequest(self): pull_request_id = fixture.create_pullrequest(self, self.REPO, self.TEST_PR_SRC, self.TEST_PR_DST, u'close test')