cli_runner = <click.testing.CliRunner object at 0x7ff632dc89e8>
swh_config = '/tmp/pytest-of-jenkins/pytest-0/test_cli_journal_client_index_3/indexer.yml'
kafka_prefix = 'nnwddonxcr', kafka_server = '127.0.0.1:36881'
consumer = <cimpl.Consumer object at 0x7ff632c32b88>
idx_storage = <swh.indexer.storage.IndexerStorage object at 0x7ff632e666d8>
storage = <swh.storage.postgresql.storage.Storage object at 0x7ff632da62e8>
mocker = <pytest_mock.plugin.MockerFixture object at 0x7ff632dc8b00>
swh_indexer_config = {'compute_checksums': ['blake2b512'], 'indexer_storage': {'cls': 'local', 'db': "user=postgres password=xxx dbname=tes...cheduler': {'cls': 'local', 'db': "user=postgres password=xxx dbname=tests host=127.0.0.1 port=20399 options=''"}, ...}
indexer_name = '*'
@pytest.mark.parametrize("indexer_name", ["extrinsic-metadata", "*"])
def test_cli_journal_client_index__origin_extrinsic_metadata(
cli_runner,
swh_config,
kafka_prefix: str,
kafka_server,
consumer: Consumer,
idx_storage,
storage,
mocker,
swh_indexer_config,
indexer_name: str,
):
"""Test the 'swh indexer journal-client' cli tool."""
journal_writer = get_journal_writer(
"kafka",
brokers=[kafka_server],
prefix=kafka_prefix,
client_id="test producer",
value_sanitizer=lambda object_type, value: value,
flush_timeout=3, # fail early if something is going wrong
)
origin = Origin("http://example.org/repo.git")
storage.origin_add([origin])
raw_extrinsic_metadata = attr.evolve(REMD, target=origin.swhid())
raw_extrinsic_metadata = attr.evolve(
raw_extrinsic_metadata, id=raw_extrinsic_metadata.compute_hash()
)
journal_writer.write_additions("raw_extrinsic_metadata", [raw_extrinsic_metadata])
result = cli_runner.invoke(
indexer_cli_group,
[
"-C",
swh_config,
"journal-client",
indexer_name,
"--broker",
kafka_server,
"--prefix",
kafka_prefix,
"--group-id",
"test-consumer",
"--stop-after-objects",
1,
],
catch_exceptions=False,
)
# Check the output
expected_output = "Done.\n"
assert result.exit_code == 0, result.output
assert result.output == expected_output
results = idx_storage.origin_extrinsic_metadata_get([origin.url])
expected_results = [
OriginExtrinsicMetadataRow(
id=origin.url,
from_remd_id=raw_extrinsic_metadata.id,
tool={"id": 1, **swh_indexer_config["tools"]},
mappings=["github"],
metadata={
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"type": "https://forgefed.org/ns#Repository",
"name": "test software",
},
)
]
> assert sorted(results, key=lambda r: r.id) == expected_results
E AssertionError: assert [] == [OriginExtrin...s=['github'])]
E Right contains one more item: OriginExtrinsicMetadataRow(indexer_configuration_id=None, tool={'id': 1, 'name': 'file', 'version': '1:5.30-1+deb9u1',... 'name': 'test software'}, from_remd_id=b'j%\x1a\x9d`9 v\xc1\n\x0c\xfd;Y\x12\xd6\xcc\xd0\x86\xd1', mappings=['github'])
E Full diff:
E - [OriginExtrinsicMetadataRow(indexer_configuration_id=None, tool={'id': 1, 'name': 'file', 'version': '1:5.30-1+deb9u1', 'configuration': {'type': 'library', 'debian-package': 'python3-magic'}}, id='http://example.org/repo.git', metadata={'@context': 'https://doi.org/10.5063/schema/codemeta-2.0', 'type': 'https://forgefed...
E
E ...Full output truncated (2 lines hidden), use '-vv' to show
.tox/py3/lib/python3.7/site-packages/swh/indexer/tests/test_cli.py:733: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Jul 21 2022, 12:04 PM