Changeset View
Changeset View
Standalone View
Standalone View
swh/journal/tests/test_cli.py
# Copyright (C) 2019 The Software Heritage developers | # Copyright (C) 2019 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import functools | import functools | ||||
import logging | import logging | ||||
import re | import re | ||||
import tempfile | import tempfile | ||||
from subprocess import Popen | from subprocess import Popen | ||||
from typing import Tuple | from typing import Any, Dict, Tuple | ||||
from unittest.mock import patch | from unittest.mock import patch | ||||
from click.testing import CliRunner | from click.testing import CliRunner | ||||
from confluent_kafka import Producer | from confluent_kafka import Producer | ||||
import pytest | import pytest | ||||
from swh.objstorage.backends.in_memory import InMemoryObjStorage | from swh.objstorage.backends.in_memory import InMemoryObjStorage | ||||
from swh.storage.in_memory import Storage | from swh.storage.in_memory import Storage | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | producer = Producer({ | ||||
'enable.idempotence': 'true', | 'enable.idempotence': 'true', | ||||
}) | }) | ||||
snapshot = {'id': b'foo', 'branches': { | snapshot = {'id': b'foo', 'branches': { | ||||
b'HEAD': { | b'HEAD': { | ||||
'target_type': 'revision', | 'target_type': 'revision', | ||||
'target': b'\x01'*20, | 'target': b'\x01'*20, | ||||
} | } | ||||
}} | }} # type: Dict[str, Any] | ||||
producer.produce( | producer.produce( | ||||
topic=kafka_prefix+'.snapshot', | topic=kafka_prefix+'.snapshot', | ||||
key=key_to_kafka(snapshot['id']), | key=key_to_kafka(snapshot['id']), | ||||
value=value_to_kafka(snapshot), | value=value_to_kafka(snapshot), | ||||
) | ) | ||||
producer.flush() | producer.flush() | ||||
logger.debug('Flushed producer') | logger.debug('Flushed producer') | ||||
▲ Show 20 Lines • Show All 125 Lines • Show Last 20 Lines |