summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/tests/test_ops.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-09-25 01:17:32 +0200
committerChristophe Besson <cbesson@gmail.com>2026-09-25 01:17:32 +0200
commit320620a18399eb43c4d9056e9fe4c3ffac8fcfd4 (patch)
treea7eb9f0c0c3428fcb20a245d2a5b2b828a8a1a8e /packages/meshbay-node/tests/test_ops.py
parent387138410532daad174ed602fd03f4f979cd3d81 (diff)
downloadmeshbay-320620a18399eb43c4d9056e9fe4c3ffac8fcfd4.tar.gz
test(node): read ops wherever it is split
The tests that read ops.py for an absence (fastapi, a TOML path without as_posix, the reference app's name) and the one counting operations by module now take every file of ops.py or the ops package. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-node/tests/test_ops.py')
-rw-r--r--packages/meshbay-node/tests/test_ops.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/packages/meshbay-node/tests/test_ops.py b/packages/meshbay-node/tests/test_ops.py
index 083f31e..d49d3fa 100644
--- a/packages/meshbay-node/tests/test_ops.py
+++ b/packages/meshbay-node/tests/test_ops.py
@@ -20,6 +20,7 @@ from meshbay_node import ops
from meshbay_node.indexer.group_index import GroupIndex
from meshbay_node.roots import RootSet
from meshbay_node.transport.quic_server import Denylist
+from node_source import ops_source
from conftest import one_root
@@ -44,13 +45,15 @@ def test_operations_take_state_and_nothing_web_shaped():
second copy. Every public operation therefore takes `state` first and
returns plain data.
"""
- # Defined here, not merely visible here: an async helper imported into the
- # module (`off_disk`, say) is not an operation, and reporting it as one says
+ # Defined in `ops`, not merely visible there: an async helper imported into
+ # it (`off_disk`, say) is not an operation, and reporting it as one says
# nothing about a second implementation appearing. Every real operation is
- # written in this module, so nothing is lost by asking.
+ # written in the module or in the package it is split into, so nothing is
+ # lost by asking.
public = [(n, f) for n, f in vars(ops).items()
if inspect.iscoroutinefunction(f) and not n.startswith("_")
- and getattr(f, "__module__", None) == ops.__name__]
+ and (getattr(f, "__module__", "") == ops.__name__
+ or getattr(f, "__module__", "").startswith(ops.__name__ + "."))]
assert len(public) > 30, "operations have gone missing — did the module move?"
for name, fn in public:
params = list(inspect.signature(fn).parameters)
@@ -82,7 +85,7 @@ def test_the_http_adapter_adds_no_logic():
def test_op_errors_carry_a_status_without_importing_http():
- source = inspect.getsource(ops)
+ source = ops_source()
for forbidden in ("JSONResponse", "fastapi", "starlette", "HTTPException"):
assert forbidden not in source, (
f"ops imports {forbidden} — it must not know which adapter called it")
@@ -400,7 +403,7 @@ def test_every_path_written_into_node_toml_goes_through_as_posix():
not run on.
"""
import re
- source = inspect.getsource(ops)
+ source = ops_source()
# Every f-string interpolation that lands on the right of a TOML `path =`.
writes = re.findall(r'path\s*=\s*\\?"\{([^}]+)\}', source)
assert writes, "no TOML path writer found — did the config writer move?"