tests (e2e/CLI): tests for Pubsub Cache Search
fix 361
This commit is contained in:
parent
4ca6c043ac
commit
33d452e0cc
1 changed files with 42 additions and 0 deletions
|
|
@ -141,6 +141,48 @@ class TestLiberviaCliPubsub:
|
|||
).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"
|
||||
|
|
|
|||
Loading…
Reference in a new issue