wardrobe test test_creation_time failed in CI
https://gitlab.esrf.fr/bliss/bliss/-/jobs/925591
___________________________ test_creation_time[True] ___________________________
session = <bliss.common.session.Session object at 0x7f7eda442a60>
caching = True
@pytest.mark.parametrize("caching", [False, True])
def test_creation_time(session, caching):
drinks = ParametersWardrobe("drinks", connection=get_redis_proxy(caching=caching))
# an empty Wardrobe has only creation/access info
assert len(drinks.to_dict(export_properties=True)) == 3
assert "wine" not in drinks.instances
drinks.switch("wine")
def str2datetime(string):
return datetime.datetime.strptime(string, "%Y-%m-%d %H:%M:%S")
# epsilon time bellow which time comparison is considered to be the same
# This value is pretty big to make sure the CI machine is fast enough
epsilon = datetime.timedelta(seconds=2).total_seconds()
# creation and last access was done now
now = datetime.datetime.now()
creation_date = str2datetime(drinks.creation_date)
assert creation_date.timestamp() == pytest.approx(now.timestamp(), abs=epsilon)
last_accessed = str2datetime(drinks.last_accessed)
assert last_accessed.timestamp() == pytest.approx(now.timestamp(), abs=epsilon)
# a later access update the last access time
gevent.sleep(1)
drinks.creation_date # access it => will change 'last_accessed' if not using caching
now = datetime.datetime.now()
last_accessed2 = str2datetime(drinks.last_accessed)
if caching:
> assert last_accessed == last_accessed2, "last_accessed was not cached"
E AssertionError: last_accessed was not cached
E assert datetime.datetime(2024, 1, 21, 12, 14, 35) == datetime.datetime(2024, 1, 21, 12, 14, 36)
tests/config/test_wardrobe.py:262: AssertionError
---------------------------- Captured stdout setup -----------------------------
test_session: Executing setup file...
TEST_SESSION INITIALIZED
Loading [/tmp/pytest-of-root/pytest-0/beacon0/test_configuration/sessions/scripts/script6.py]
Exported [mc] namespace in session.
...
Edited by Cyril Guilloud