Mercurial > libervia-backend
diff tests/e2e/libervia-cli/test_libervia-cli.py @ 3674:eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
fix 361
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 08 Sep 2021 17:58:48 +0200 |
parents | 9e491b2bab88 |
children | 7e51cfc36d4e |
line wrap: on
line diff
--- 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"