Changeset View
Changeset View
Standalone View
Standalone View
swh/search/tests/test_cli.py
Show All 15 Lines | |||||
from swh.search.cli import search_cli_group | from swh.search.cli import search_cli_group | ||||
CLI_CONFIG = """ | CLI_CONFIG = """ | ||||
search: | search: | ||||
cls: elasticsearch | cls: elasticsearch | ||||
args: | args: | ||||
hosts: | hosts: | ||||
- '%(elasticsearch_host)s' | - '%(elasticsearch_host)s' | ||||
index_prefix: test | |||||
""" | """ | ||||
JOURNAL_OBJECTS_CONFIG_TEMPLATE = """ | JOURNAL_OBJECTS_CONFIG_TEMPLATE = """ | ||||
journal: | journal: | ||||
brokers: | brokers: | ||||
- {broker} | - {broker} | ||||
prefix: {prefix} | prefix: {prefix} | ||||
group_id: {group_id} | group_id: {group_id} | ||||
▲ Show 20 Lines • Show All 352 Lines • ▼ Show 20 Lines | journal: | ||||
with pytest.raises(ValueError, match="object_types"): | with pytest.raises(ValueError, match="object_types"): | ||||
invoke( | invoke( | ||||
False, | False, | ||||
# Missing --object-types (and no config key) will make the cli raise | # Missing --object-types (and no config key) will make the cli raise | ||||
["journal-client", "objects", "--stop-after-objects", "1"], | ["journal-client", "objects", "--stop-after-objects", "1"], | ||||
journal_cfg, | journal_cfg, | ||||
elasticsearch_host=elasticsearch_host, | elasticsearch_host=elasticsearch_host, | ||||
) | ) | ||||
def test__initialize__with_prefix(swh_search_with_prefix, elasticsearch_host): | |||||
"""Initializing the index with a prefix should create an <prefix>_origin index""" | |||||
assert swh_search_with_prefix.origin_index == "test_origin" | |||||
def test__initialize__without_prefix(swh_search_without_prefix, elasticsearch_host): | |||||
"""Initializing the index without a prefix should create an origin index""" | |||||
assert swh_search_without_prefix.origin_index == "origin" |