cultcache-py: pin the put_envelopes tail refusal; README says a held-by-two-types conflict is CultCacheError on load, SchemaConflictError on write
All checks were successful
CultMesh portability and performance / ubuntu-latest reactive semantics and leases (pull_request) Successful in 18m38s
All checks were successful
CultMesh portability and performance / ubuntu-latest reactive semantics and leases (pull_request) Successful in 18m38s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
562d318b48
commit
e8fa1c4d8f
2 changed files with 25 additions and 1 deletions
|
|
@ -69,7 +69,7 @@ store.
|
|||
|
||||
## Public Surface
|
||||
|
||||
- `CultCacheError` (a `RuntimeError`, exported from the package root): the cache's refusals (a unique-index violation, a key held by two types) and `convert`'s (`source_missing`, `destination_exists`, a refused record). Import it from `cultcache_py`, not from the private `cache` module.
|
||||
- `CultCacheError` (a `RuntimeError`, exported from the package root): the cache's refusals (a unique-index violation; a key held by two types on load, while the same conflict on a write is a `SchemaConflictError`, a `ValueError`) and `convert`'s (`source_missing`, `destination_exists`, a refused record). Import it from `cultcache_py`, not from the private `cache` module.
|
||||
- `define_document_type(...)`
|
||||
- `define_database_entry_type(...)`
|
||||
- `database_entry_field(...)`
|
||||
|
|
|
|||
|
|
@ -126,6 +126,30 @@ class RootExportTests(unittest.TestCase):
|
|||
cache.put_envelope(document, CultCacheEnvelope.create(key="k", type=document.type, payload=tailed))
|
||||
self.assertEqual(store.pull_all(), [], type(store).__name__)
|
||||
|
||||
def test_a_batch_with_one_tailed_envelope_is_refused_whole_and_earlier_records_stay(self) -> None:
|
||||
document = define_document_type("tests.tail_batch")
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
for store in (
|
||||
SingleFileMessagePackBackingStore(Path(directory) / "batch.cc"),
|
||||
JsonLinesBackingStore(Path(directory) / "batch.jsonl"),
|
||||
):
|
||||
name = type(store).__name__
|
||||
cache = CultCache.builder().register_document_type(document).add_generic_store(store).build()
|
||||
cache.put(document, "early", {"a": 0})
|
||||
before = store.pull_all()
|
||||
good = document.encode_payload({"a": 1})
|
||||
with self.assertRaisesRegex(ValueError, r"1 bytes after its first MessagePack value \(refused on read\)"):
|
||||
cache.put_envelopes(
|
||||
document,
|
||||
[
|
||||
CultCacheEnvelope.create(key="good", type=document.type, payload=good),
|
||||
CultCacheEnvelope.create(key="bad", type=document.type, payload=good + b"\xc0"),
|
||||
],
|
||||
)
|
||||
self.assertEqual(store.pull_all(), before, name)
|
||||
self.assertEqual([item.key for item in before], ["early"], name)
|
||||
self.assertIsNone(cache.get(document, "good"), name)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Reference in a new issue