Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/tests/test_cassandra.py
Show First 20 Lines • Show All 534 Lines • ▼ Show 20 Lines | def test_directory_add_atomic(self, swh_storage, sample_data, mocker, insert_algo): | ||||
ie. checks directories are added somewhat atomically.""" | ie. checks directories are added somewhat atomically.""" | ||||
# Disable the journal writer, it would detect the CrashyEntry exception too | # Disable the journal writer, it would detect the CrashyEntry exception too | ||||
# early for this test to be relevant | # early for this test to be relevant | ||||
swh_storage.journal_writer.journal = None | swh_storage.journal_writer.journal = None | ||||
mocker.patch.object(swh_storage, "_directory_entries_insert_algo", insert_algo) | mocker.patch.object(swh_storage, "_directory_entries_insert_algo", insert_algo) | ||||
class CrashyEntry(DirectoryEntry): | class CrashyEntry(DirectoryEntry): | ||||
def __init__(self): | def __init__(self): | ||||
pass | super().__init__(**{**directory.entries[0].to_dict(), "name": b"crash"}) | ||||
vlorentz: FYI I think you should be able to do this, but no big deal | |||||
Done Inline ActionsComputer says no: self = <[TypeError("a bytes-like object is required, not '_Nothing'") raised in repr()] CrashyEntry object at 0x7f7aa159d5e0> def __init__(self): > super().__init__(**directory.entries[0].to_dict(), name=b"crash") E TypeError: swh.model.model.DirectoryEntry.__init__() got multiple values for keyword argument 'name' swh/storage/tests/test_cassandra.py:543: TypeError anlambert: Computer says no:
```
self = <[TypeError("a bytes-like object is required, not '_Nothing'")… | |||||
def to_dict(self): | def to_dict(self): | ||||
return {**directory.entries[0].to_dict(), "perms": "abcde"} | return {**super().to_dict(), "perms": "abcde"} | ||||
directory = self._directory_with_entries(sample_data, BATCH_INSERT_MAX_SIZE) | directory = self._directory_with_entries(sample_data, BATCH_INSERT_MAX_SIZE) | ||||
entries = directory.entries | entries = directory.entries | ||||
directory = attr.evolve(directory, entries=entries + (CrashyEntry(),)) | directory = attr.evolve(directory, entries=entries + (CrashyEntry(),)) | ||||
with pytest.raises(TypeError): | with pytest.raises(TypeError): | ||||
swh_storage.directory_add([directory]) | swh_storage.directory_add([directory]) | ||||
▲ Show 20 Lines • Show All 191 Lines • Show Last 20 Lines |
FYI I think you should be able to do this, but no big deal