tractor/tests
Tyler Goodlet c2fc6293aa Extend codec test to for msg-spec parameterizing
Set a diff `Msg.pld` spec per test and then send multiple types to
a child actor making sure the child can only send certain types over
a stream and fails with validation or decode errors ow. The test is also
param-ed both with and without hooks demonstrating how a custom type,
`NamespacePath`, needs them for effective use. The subactor IPC context
child is passed a `expect_ipc_send: dict` which relays the values along
with their expected `.send()`-ability.

Deats on technical refinements:
------ - ------
- added a `iter_maybe_sends()` send-value-as-msg-auditor and predicate
  generator (literally) so as to be able to pre-determine if given the
  current codec and `send_values` which values are expected to be IPC
  transmittable.
- as per ^, the diff value-msgs are first round-tripped inside
  a `Started` msg using the configured codec in the parent/root actor
  before bothering with using IPC primitives + a subactor; this is how
  the `expect_ipc_send` table is generated initially.
- for serializing the specs (`Union[Type]`s as required by `msgspec`),
  added a pair of codec hooks: `enc/dec_type_union()` (that ideally we
  move into a `.msg` submod eventually) which code the type-values as
  a `list[str]` of names.
  - the `dec_` hook had to be modified to NOT raise an error when an
    invalid/unhandled value arrives, this is because we do NOT want the
    RPC msg handling loop to raise on the `async for msg in chan:` and
    instead prefer to ignore and warn (for now, but eventually respond
    with error msg - see notes in hook body) these msgs when sent during
    a streaming phase; `Context.started()` will however error on a bad
    input for the current msg-spec since it is part of the "cheap"
    dialog (again see notes in `._context`) wherein the `Started` msg
    is always roundtripped prior to `Channel.send()` to guarantee
    the child adheres to its own spec.
- tossed in lotsa `print()`s for console groking of the run progress.

Further notes on typed-msging breaking cancellation:
------ - ------
- turns out since the runtime's cancellation implementation, being done
  with `Actor.cancel()` methods and friends will actually break when
  a stringent spec is applied (eg. a single type-spec) since the return
  values from said methods are generally `bool`s..
- this means we do indeed need special handling of "runtime RPC method
  invocations" since ideally a user's msg-spec choices do not break core
  functionality on them XD
=> The obvi solution is to add a/some special sub-`Msg` types for such
  cases, possibly just a `RuntimeReturn(Return)` type that will always
  include a `.pld: bool` for these cancel methods such that their
  results are always handled without msg type errors.

More to come on a (hopefully) elegant solution to that last bit!
2025-03-24 14:04:51 -04:00
..
__init__.py Add `tests/__init__.py` for `.conftest` imports 2025-03-20 20:53:54 -04:00
conftest.py Rename fixture `arb_addr` -> `reg_addr` and set the session value globally as `._root._default_lo_addrs` 2025-03-20 19:50:31 -04:00
test_2way.py Move context-streaming operational tests into one mod 2021-12-06 16:45:44 -05:00
test_advanced_faults.py Use `._testing.break_ipc()` in final advanced fault test child ctx 2025-03-24 14:04:51 -04:00
test_advanced_streaming.py Tweak some tests for spurious failues 2025-03-16 15:22:01 -04:00
test_cancellation.py Add `tests/__init__.py` for `.conftest` imports 2025-03-20 20:53:54 -04:00
test_caps_based_msging.py Extend codec test to for msg-spec parameterizing 2025-03-24 14:04:51 -04:00
test_child_manages_service_nursery.py Adjust all `RemoteActorError.type` using tests 2025-03-20 20:35:02 -04:00
test_clustering.py Add (back) a `tractor._testing` sub-pkg 2025-03-16 15:28:28 -04:00
test_context_stream_semantics.py TOSQUASH f2ce4a3, timeout bump 2025-03-24 14:04:51 -04:00
test_debugger.py Refine and test `tractor.pause_from_sync()` 2025-03-20 22:37:51 -04:00
test_discovery.py Reapply "Port all tests to new `reg_addr` fixture name" 2025-03-20 19:50:31 -04:00
test_docs_examples.py Get remaining suites passing.. 2025-03-20 20:35:02 -04:00
test_infected_asyncio.py Provision for infected-`asyncio` debug mode support 2025-03-20 22:37:51 -04:00
test_inter_peer_cancellation.py Extend inter-peer cancel tests for "inceptions" 2025-03-20 20:35:02 -04:00
test_legacy_one_way_streaming.py Reapply "Port all tests to new `reg_addr` fixture name" 2025-03-20 19:50:31 -04:00
test_local.py Reapply "Port all tests to new `reg_addr` fixture name" 2025-03-20 19:50:31 -04:00
test_multi_program.py Reapply "Port all tests to new `reg_addr` fixture name" 2025-03-20 19:50:31 -04:00
test_pubsub.py Reapply "Port all tests to new `reg_addr` fixture name" 2025-03-20 19:50:31 -04:00
test_resource_cache.py Bump timeout on resource cache test a bitty bit. 2025-03-14 14:14:53 -04:00
test_rpc.py Adjust all `RemoteActorError.type` using tests 2025-03-20 20:35:02 -04:00
test_runtime.py Drop now-deprecated deps on modern `trio`/Python 2025-03-16 16:06:24 -04:00
test_spawning.py Get remaining suites passing.. 2025-03-20 20:35:02 -04:00
test_task_broadcasting.py Reapply "Port all tests to new `reg_addr` fixture name" 2025-03-20 19:50:31 -04:00
test_trioisms.py Drop now-deprecated deps on modern `trio`/Python 2025-03-16 16:06:24 -04:00