swh_search = <swh.search.elasticsearch.ElasticSearch object at 0x7f6b3398f6a0>
elasticsearch_host = '127.0.0.1:56843', kafka_prefix = 'qjgvknazxl'
kafka_server = '127.0.0.1:51639'
def test__journal_client__origin_visit_status(
swh_search, elasticsearch_host, kafka_prefix: str, kafka_server
):
"""Subscribing to origin-visit-status should result in swh-search indexation
"""
origin_foobar = {"url": "http://baz.foobar"}
producer = Producer(
{
"bootstrap.servers": kafka_server,
"client.id": "test search origin visit status producer",
"acks": "all",
}
)
topic = f"{kafka_prefix}.origin_visit_status"
value = value_to_kafka(
{
"origin": origin_foobar["url"],
"visit": 1,
"snapshot": None,
"status": "full",
}
)
producer.produce(topic=topic, key=b"bogus-origin-visit-status", value=value)
journal_objects_config = JOURNAL_OBJECTS_CONFIG_TEMPLATE.format(
broker=kafka_server, prefix=kafka_prefix, group_id="test-consumer"
)
result = invoke(
False,
[
"journal-client",
"objects",
"--stop-after-objects",
"1",
"--prefix",
kafka_prefix,
"--object-type",
"origin_visit_status",
],
journal_objects_config,
> elasticsearch_host=elasticsearch_host,
)
.tox/py3/lib/python3.7/site-packages/swh/search/tests/test_cli.py:204:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/search/tests/test_cli.py:50: in invoke
raise result.exception
.tox/py3/lib/python3.7/site-packages/click/testing.py:329: in invoke
cli.main(args=args or (), prog_name=prog_name, **extra)
.tox/py3/lib/python3.7/site-packages/click/core.py:782: in main
rv = self.invoke(ctx)
.tox/py3/lib/python3.7/site-packages/click/core.py:1259: in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
.tox/py3/lib/python3.7/site-packages/click/core.py:1259: in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
.tox/py3/lib/python3.7/site-packages/click/core.py:1066: in invoke
return ctx.invoke(self.callback, **ctx.params)
.tox/py3/lib/python3.7/site-packages/click/core.py:610: in invoke
return callback(*args, **kwargs)
.tox/py3/lib/python3.7/site-packages/click/decorators.py:21: in new_func
return f(get_current_context(), *args, **kwargs)
.tox/py3/lib/python3.7/site-packages/swh/search/cli.py:102: in journal_client_objects
nb_messages = client.process(worker_fn)
.tox/py3/lib/python3.7/site-packages/swh/journal/client.py:265: in process
batch_processed, at_eof = self.handle_messages(messages, worker_fn)
.tox/py3/lib/python3.7/site-packages/swh/journal/client.py:292: in handle_messages
worker_fn(dict(objects))
.tox/py3/lib/python3.7/site-packages/swh/search/journal_client.py:28: in process_journal_objects
process_origin_visit_statuses(messages["origin_visit_status"], search)
.tox/py3/lib/python3.7/site-packages/swh/search/journal_client.py:68: in process_origin_visit_statuses
for visit_status in visit_statuses
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.0 = <list_iterator object at 0x7f6b3397f4a8>
{
"url": (visit_status["origin"]),
"has_visits": True,
"nb_visit": visit_status["visit"],
"last_visit_date": str(visit_status["date"]),
}
for visit_status in visit_statuses
> if visit_status["status"] == "full"
]
E KeyError: 'date'
.tox/py3/lib/python3.7/site-packages/swh/search/journal_client.py:69: KeyError
TEST RESULT
TEST RESULT
- Run At
- Jun 7 2021, 5:28 PM