# HG changeset patch # User Goffi # Date 1631116728 -7200 # Node ID eeb8be32d644a5cb8963edc7e5eb39f2e3dd4c56 # Parent bd13391ee29eecc833fb6a19f440c378638e7376 tests (e2e/CLI): tests for Pubsub Cache Search fix 361 diff -r bd13391ee29e -r eeb8be32d644 tests/e2e/libervia-cli/test_libervia-cli.py --- a/tests/e2e/libervia-cli/test_libervia-cli.py Wed Sep 08 17:58:48 2021 +0200 +++ b/tests/e2e/libervia-cli/test_libervia-cli.py Wed Sep 08 17:58:48 2021 +0200 @@ -141,6 +141,48 @@ ).strip() assert built_uri == "xmpp:pubsub.example.net?;node=some_node;item=some_item" + def test_cache_search(self, li_json): + """A Full-Text Search query can be done""" + sk_txt = "this is a blog post about Slovakia" + fr_txt = "this is a blog post about France" + nc_txt = "this is a blog post about New Caledonia" + au_txt = "this is a blog post about Australia" + li.blog.set( + "-t", "travel", "-t", "europe", + _in=sk_txt, + syntax="markdown" + ) + li.blog.set( + "-t", "travel", "-t", "europe", + _in=fr_txt, + syntax="markdown" + ) + li.blog.set( + "-t", "travel", "-t", "south pacific", + _in=nc_txt, + syntax="markdown" + ) + li.blog.set( + "-t", "travel", "-t", "south pacific", + _in="this is a blog post about Australia", + title=au_txt, + syntax="markdown" + ) + # we get the blog to be 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"') + 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") + assert len(found) == 4 + 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") + assert all(i["content"] in (nc_txt, au_txt) for i in found) + class TestLiberviaCliBlog: MICROBLOG_NS = "urn:xmpp:microblog:0"