From 43dd429aa209b990a461b4401efe18846467bf49 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 12 Aug 2022 16:54:44 +0300 Subject: [PATCH] Use random to remove a cache --- tests/package/test_manager.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/package/test_manager.py b/tests/package/test_manager.py index cd1fc1a2..c1de90b1 100644 --- a/tests/package/test_manager.py +++ b/tests/package/test_manager.py @@ -18,6 +18,7 @@ import logging import os import time from pathlib import Path +from random import random import pytest import semantic_version @@ -41,11 +42,11 @@ def test_download(isolated_pio_core): lm.set_log_level(logging.ERROR) archive_path = lm.download(url, checksum) assert fs.calculate_file_hashsum("sha256", archive_path) == checksum - lm.cleanup_expired_downloads(time.time()) + lm.cleanup_expired_downloads(random()) assert os.path.isfile(archive_path) # test outdated downloads - lm.set_download_utime(archive_path, time.time() - lm.DOWNLOAD_CACHE_EXPIRE - 60) - lm.cleanup_expired_downloads(time.time()) + lm.set_download_utime(archive_path, time.time() - lm.DOWNLOAD_CACHE_EXPIRE - 1) + lm.cleanup_expired_downloads(random()) assert not os.path.isfile(archive_path) # check that key is deleted from DB with open(lm.get_download_usagedb_path(), encoding="utf8") as fp: