Mercurial > libervia-backend
diff tests/e2e/libervia-cli/test_libervia-cli.py @ 3715:b9718216a1c0 0.9
merge bookmark 0.9
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 01 Dec 2021 16:13:31 +0100 |
parents | eeb8be32d644 |
children | 7e51cfc36d4e |
line wrap: on
line diff
--- a/tests/e2e/libervia-cli/test_libervia-cli.py Tue Nov 30 23:31:09 2021 +0100 +++ b/tests/e2e/libervia-cli/test_libervia-cli.py Wed Dec 01 16:13:31 2021 +0100 @@ -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"