diff --git a/src/controller/base.py b/src/controller/base.py index 553f5531..f2e688ac 100644 --- a/src/controller/base.py +++ b/src/controller/base.py @@ -377,4 +377,4 @@ def update(self, content): self._status = self.STATUS.NOT_MODIFIED.value else: # raw field changed self._status = self.STATUS.UPDATED.value - self._entity.raw = content.raw + self._entity.raw = content.raw diff --git a/src/tests/test_controller.py b/src/tests/test_controller.py index bd9d95f7..ea8c0be8 100644 --- a/src/tests/test_controller.py +++ b/src/tests/test_controller.py @@ -4,7 +4,7 @@ import json import os import time -from datetime import datetime, timezone +from datetime import datetime, timedelta, timezone import elasticsearch import pytest @@ -380,6 +380,10 @@ def test_refresh_status(): assert mygene.webdoc.timestamp > datetime(2020, 1, 1) _ts0 = mygene.webdoc.timestamp + original_last_updated = mygene.last_updated.replace(microsecond=0, tzinfo=None) + one_hour_before = (datetime.now() - timedelta(hours=1)).replace(microsecond=0) + assert original_last_updated > one_hour_before + mygene.save() refresh() @@ -393,9 +397,15 @@ def test_refresh_status(): assert "components" in mygene assert mygene.webdoc.timestamp > _ts0 + current_last_updated = mygene.last_updated.replace(microsecond=0, tzinfo=None) + assert current_last_updated == original_last_updated + mygene.save() refresh() + # confirm last_updated is not changed after refresh + assert mygene.last_updated.replace(microsecond=0, tzinfo=None) == current_last_updated + mygene_doc = SmartAPIDoc.get(MYGENE_ID) assert mygene_doc._status.refresh_status == 200 assert "components" in mygene_doc @@ -408,6 +418,9 @@ def test_refresh_status(): mygene.save() refresh() + # confirm last_updated is not changed after refresh + assert mygene.last_updated.replace(microsecond=0, tzinfo=None) == current_last_updated + mygene_doc = SmartAPIDoc.get(MYGENE_ID) assert mygene_doc._status.refresh_status == 404 assert "components" in mygene_doc @@ -432,6 +445,9 @@ def test_refresh_status(): mygene.save() refresh() + # confirm last_updated is not changed after refresh + assert mygene.last_updated.replace(microsecond=0, tzinfo=None) == current_last_updated + mygene_doc = SmartAPIDoc.get(MYGENE_ID) assert mygene_doc._status.refresh_status == 499 assert "components" in mygene_doc