diff --git a/tests/e2e/libervia-cli/test_libervia-cli.py b/tests/e2e/libervia-cli/test_libervia-cli.py index 15087df3..7ad41746 100644 --- a/tests/e2e/libervia-cli/test_libervia-cli.py +++ b/tests/e2e/libervia-cli/test_libervia-cli.py @@ -21,6 +21,7 @@ import shutil import pytest import sh from sh import li +from time import sleep from sat.tools.common import uri @@ -168,19 +169,35 @@ class TestLiberviaCliPubsub: title=au_txt, syntax="markdown" ) - # we get the blog to be activate the cache for it + # we get the blog to activate the cache for it li.blog.get(max_items=1) # FTS - found = li_json.pubsub.cache.search(type="blog", fts='Slovakia OR "New Caledonia"') + found = [] + for __ in range(5): + found = li_json.pubsub.cache.search( + type="blog", fts='Slovakia OR "New Caledonia"' + ) + if found: + break + else: + # retrieving blog triggers the caching, but it's done in parallel + # thus we may have nothing in cache yet + sleep(0.5) assert len(found) == 2 assert all(i["content"] in (sk_txt, nc_txt) for i in found) # search by field - found = li_json.pubsub.cache.search("-F", "tags", "overlap", "travel", type="blog") + found = li_json.pubsub.cache.search( + "-F", "tags", "overlap", "travel", type="blog" + ) assert len(found) == 4 - found = li_json.pubsub.cache.search("-F", "tags", "overlap", "europe", type="blog") + found = li_json.pubsub.cache.search( + "-F", "tags", "overlap", "europe", type="blog" + ) assert len(found) == 2 assert all(i["content"] in (sk_txt, fr_txt) for i in found) - found = li_json.pubsub.cache.search("-F", "tags", "ioverlap", "SOUTH PACIFIC", type="blog") + found = li_json.pubsub.cache.search( + "-F", "tags", "ioverlap", "SOUTH PACIFIC", type="blog" + ) assert all(i["content"] in (nc_txt, au_txt) for i in found)