changeset 6808:71033bd37b4c

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.
author domruf <dominikruf@gmail.com>
date Tue, 08 Aug 2017 21:35:20 +0200
parents d43cf470e625
children 4bd2c3590a22
files kallithea/model/db.py kallithea/tests/api/api_base.py
diffstat 2 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/model/db.py	Sun Aug 13 17:19:18 2017 +0200
+++ b/kallithea/model/db.py	Tue Aug 08 21:35:20 2017 +0200
@@ -2312,7 +2312,7 @@
     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,
             )
 
--- a/kallithea/tests/api/api_base.py	Sun Aug 13 17:19:18 2017 +0200
+++ b/kallithea/tests/api/api_base.py	Tue Aug 08 21:35:20 2017 +0200
@@ -2501,7 +2501,7 @@
         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 @@
             "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')