kafka_prefix = 'uwupjrfisl', kafka_consumer_group = 'test-consumer-uwupjrfisl'
kafka_server = '127.0.0.1:60177', privileged = True
@pytest.mark.parametrize("privileged", [True, False])
def test_storage_play_anonymized(
kafka_prefix: str, kafka_consumer_group: str, kafka_server: str, privileged: bool,
):
"""Optimal replayer scenario.
This:
- writes objects to the topic
- replayer consumes objects from the topic and replay them
This tests the behavior with both a privileged and non-privileged replayer
"""
writer_config = {
"cls": "kafka",
"brokers": [kafka_server],
"client_id": "kafka_writer",
"prefix": kafka_prefix,
"anonymize": True,
}
src_config: Dict[str, Any] = {"cls": "memory", "journal_writer": writer_config}
storage = get_storage(**src_config)
# Fill the src storage
nb_sent = 0
for obj_type, objs in TEST_OBJECTS.items():
if obj_type in ("origin_visit", "origin_visit_status"):
# these are unrelated with what we want to test here
continue
method = getattr(storage, obj_type + "_add")
> method(objs)
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/test_replay.py:353:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/storage/cassandra/storage.py:644: in release_add
self.journal_writer.release_add(releases)
.tox/py3/lib/python3.7/site-packages/swh/storage/writer.py:93: in release_add
self.write_additions("release", releases)
.tox/py3/lib/python3.7/site-packages/swh/storage/writer.py:67: in write_additions
self.journal.write_additions(object_type, values)
.tox/py3/lib/python3.7/site-packages/swh/journal/writer/kafka.py:247: in write_additions
self._write_addition(object_type, object_)
.tox/py3/lib/python3.7/site-packages/swh/journal/writer/kafka.py:222: in _write_addition
anon_object_ = object_.anonymize()
.tox/py3/lib/python3.7/site-packages/swh/model/model.py:490: in anonymize
return attr.evolve(self, author=author)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
inst = Release(name=b'v0.0.1', message=b'foo', target=b'\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\...et=120, negative_utc=False), metadata=None, id=b'\x80Y\xdcN\x17\xfc\xd0\xe5\x1c\xa3\xbc\xd6\xb8\x0fEw\xd2\x81\xfd\x08')
changes = {'author': Person(fullname=b',&\xb4kh\xff\xc6\x8f\xf9\x9bE<\x1d0A4\x13B-pd\x83\xbf\xa0\xf9\x8a^\x88bf\xe7\xae', name=None, email=None), 'message': b'foo', 'name': b'v0.0.1', 'synthetic': False, ...}
cls = <class 'swh.model.model.Release'>
attrs = (Attribute(name='name', default=NOTHING, validator=<function type_validator.<locals>._validator at 0x7f121880d1e0>, re...rue, metadata=mappingproxy({}), type=<class 'bytes'>, converter=None, kw_only=False, inherited=False, on_setattr=None))
a = Attribute(name='author', default=None, validator=_AndValidator(_validators=(<function type_validator.<locals>._validat..., type=typing.Union[swh.model.model.Person, NoneType], converter=None, kw_only=False, inherited=False, on_setattr=None)
attr_name = 'author', init_name = 'author'
value = Person(fullname=b'foo', name=b'foo', email=b'')
def evolve(inst, **changes):
"""
Create a new instance, based on *inst* with *changes* applied.
:param inst: Instance of a class with ``attrs`` attributes.
:param changes: Keyword changes in the new copy. Nested ``attrs`` classes
can be updated by passing (nested) dicts of values.
:return: A copy of inst with *changes* incorporated.
:raise TypeError: If *attr_name* couldn't be found in the class
``__init__``.
:raise attr.exceptions.NotAnAttrsClassError: If *cls* is not an ``attrs``
class.
.. versionadded:: 17.1.0
"""
cls = inst.__class__
attrs = fields(cls)
for a in attrs:
if not a.init:
continue
attr_name = a.name # To deal with private attributes.
init_name = attr_name if attr_name[0] != "_" else attr_name[1:]
value = getattr(inst, attr_name)
if init_name not in changes:
# Add original value to changes
changes[init_name] = value
elif has(value):
# Evolve nested attrs classes
> changes[init_name] = evolve(value, **changes[init_name])
E TypeError: evolve() argument after ** must be a mapping, not Person
.tox/py3/lib/python3.7/site-packages/attr/_funcs.py:347: TypeError
TEST RESULT
TEST RESULT
- Run At
- May 6 2021, 12:02 PM