cli_runner = <click.testing.CliRunner object at 0x7fe943e560b8>
swh_config = '/tmp/pytest-of-jenkins/pytest-0/test_cli_journal_client_index_2/indexer.yml'
kafka_prefix = 'gijvwrxtlx', kafka_server = '127.0.0.1:41353'
consumer = <cimpl.Consumer object at 0x7fe943e70908>
idx_storage = <swh.indexer.storage.IndexerStorage object at 0x7fe943e6de10>
storage = <swh.storage.postgresql.storage.Storage object at 0x7fe943e6d278>
mocker = <pytest_mock.plugin.MockerFixture object at 0x7fe943e6d0b8>
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=27104 options=''"}, ...}
indexer_name = 'extrinsic_metadata'
@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'])] == [OriginExtrin...s=['github'])]
E At index 0 diff: 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={'id': 'http://example.org/', 'name': 'test software', 'type': 'https://forgefed.org/ns#Repository', '@context': 'https://doi.org/10.5063/schema/codemeta-2.0'}, from_remd_id=b'\xcfa\xb7b\xa7 \x9e\x0b(P\xf1\xad\xda\x9423V\xad\xdft', mappings=['github']) != OriginExtrinsicMetadataRow(indexer_configuration_id=None, tool={'id...
E
E ...Full output truncated (6 lines hidden), use '-vv' to show
.tox/py3/lib/python3.7/site-packages/swh/indexer/tests/test_cli.py:758: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Sep 16 2022, 3:00 PM