tractor/tests
Tyler Goodlet cb728e3bd6 Be mega pedantic with msg-spec building
Turns out the generics based payload speccing API, as in
https://jcristharif.com/msgspec/supported-types.html#generic-types,
DOES WORK properly as long as we don't rely on inheritance from `Msg`
a parent `Generic`..

So let's get real pedantic in the `mk_msg_spec()` internals as well as
verification in the test suite!

Fixes in `.msg.types`:
- implement (as part of tinker testing) multiple spec union building
  methods via a `spec_build_method: str` to `mk_msg_spec()` and leave a
  buncha notes around what did and didn't work:
  - 'indexed_generics' is the only method THAT WORKS and the one that
    you'd expect being closest to the `msgspec` docs (link above).
  - 'defstruct' using dynamically defined msgs => doesn't work!
  - 'types_new_class' using dynamically defined msgs but with
    `types.new_clas()` => ALSO doesn't work..

- explicitly separate the `.pld` type-constrainable by user code msg
  set into `types._payload_spec_msgs` putting the others in
  a `types._runtime_spec_msgs` and the full set defined as `.__spec__`
  (moving it out of the pkg-mod and back to `.types` as well).

- for the `_payload_spec_msgs` msgs manually make them inherit `Generic[PayloadT]`
  and (redunantly) define a `.pld: PayloadT` field.

- make `IpcCtxSpec.functype` an in line `Literal`.

- toss in some TODO notes about choosing a better `Msg.cid` type.

Fixes/tweaks around `.msg._codec`:
- rename `MsgCodec.ipc/pld_msg_spec` -> `.msg/pld_spec`
- make `._enc/._dec` non optional fields
- wow, ^facepalm^ , make sure `._ipc.MsgpackTCPStream.__init__()` uses
  `mk_codec()` since `MsgCodec` can't be (easily) constructed directly.

Get more detailed in testing:
- inside the `chk_pld_type()` helper ensure `roundtrip` is always set to
  some value, `None` by default but a bool depending on legit outcome.
  - drop input `generic`; no longer used.
  - drop the masked `typedef` loop from `Msg.__subclasses__()`.
  - for add an `expect_roundtrip: bool` and use to jump into debugger
    when any expectation doesn't match the outcome.
- use new `MsgCodec` field names (as per first section above).
- ensure the encoded msg matches the decoded one from both the ad-hoc
  decoder and codec loaded values.
- ensure the pld checking is only applied to msgs in the
  `types._payload_spec_msgs` set by `typef.__name__` filtering
  since `mk_msg_spec()` now returns the full `.types.Msg` set.
2024-03-29 19:15:00 -04:00
..
conftest.py Add (back) a `tractor._testing` sub-pkg 2024-03-13 09:09:08 -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 Adjust advanced faults test(s) for absorbed EoCs 2024-03-19 19:33:06 -04:00
test_advanced_streaming.py Tweak some tests for spurious failues 2024-03-11 10:37:34 -04:00
test_cancellation.py Adjust all `RemoteActorError.type` using tests 2024-03-19 18:08:54 -04:00
test_caps_based_msging.py Be mega pedantic with msg-spec building 2024-03-29 19:15:00 -04:00
test_child_manages_service_nursery.py Adjust all `RemoteActorError.type` using tests 2024-03-19 18:08:54 -04:00
test_clustering.py Add (back) a `tractor._testing` sub-pkg 2024-03-13 09:09:08 -04:00
test_context_stream_semantics.py Adjust all `RemoteActorError.type` using tests 2024-03-19 18:08:54 -04:00
test_debugger.py Refine and test `tractor.pause_from_sync()` 2024-03-22 19:58:25 -04:00
test_discovery.py Add (back) a `tractor._testing` sub-pkg 2024-03-13 09:09:08 -04:00
test_docs_examples.py Add (back) a `tractor._testing` sub-pkg 2024-03-13 09:09:08 -04:00
test_infected_asyncio.py Provision for infected-`asyncio` debug mode support 2024-03-25 16:09:32 -04:00
test_inter_peer_cancellation.py Extend inter-peer cancel tests for "inceptions" 2024-03-20 10:29:40 -04:00
test_legacy_one_way_streaming.py Add (back) a `tractor._testing` sub-pkg 2024-03-13 09:09:08 -04:00
test_local.py Add (back) a `tractor._testing` sub-pkg 2024-03-13 09:09:08 -04:00
test_multi_program.py Add (back) a `tractor._testing` sub-pkg 2024-03-13 09:09:08 -04:00
test_pubsub.py Add (back) a `tractor._testing` sub-pkg 2024-03-13 09:09:08 -04:00
test_resource_cache.py Bump timeout on resource cache test a bitty bit. 2024-01-03 22:27:05 -05:00
test_rpc.py Adjust all `RemoteActorError.type` using tests 2024-03-19 18:08:54 -04:00
test_runtime.py Drop now-deprecated deps on modern `trio`/Python 2024-03-13 18:41:24 -04:00
test_shm.py Pass `str` dtype for `use_str` case 2023-06-15 12:20:20 -04:00
test_spawning.py Add (back) a `tractor._testing` sub-pkg 2024-03-13 09:09:08 -04:00
test_task_broadcasting.py Port all tests to new `reg_addr` fixture name 2023-10-18 15:39:20 -04:00
test_trioisms.py Drop now-deprecated deps on modern `trio`/Python 2024-03-13 18:41:24 -04:00