connector: wanted(port) says whether anyone watches or reads a port
Docs / docs (push) Successful in 31s
Playwright Tests / test-playwright (1, 2) (push) Failing after 1m5s
Playwright Tests / test-playwright (2, 2) (push) Failing after 20s
pre-commit / pre-commit (push) Failing after 2m30s
Test Backend / test-backend (3.12) (push) Failing after 4m52s
Test Backend / test-backend (3.14) (push) Failing after 4m36s
Compose Smoke Test / test-compose (push) Failing after 24s
Playwright Tests / merge-reports (push) Failing after 2m25s
Docs / docs (push) Successful in 31s
Playwright Tests / test-playwright (1, 2) (push) Failing after 1m5s
Playwright Tests / test-playwright (2, 2) (push) Failing after 20s
pre-commit / pre-commit (push) Failing after 2m30s
Test Backend / test-backend (3.12) (push) Failing after 4m52s
Test Backend / test-backend (3.14) (push) Failing after 4m36s
Compose Smoke Test / test-compose (push) Failing after 24s
Playwright Tests / merge-reports (push) Failing after 2m25s
This commit is contained in:
@@ -306,3 +306,29 @@ def test_a_connector_publishes_bytes_as_a_media_reference(tmp_path):
|
||||
# point of a media dtype.
|
||||
MessageSpec(name="demo.frame", dtype=DType.IMAGE).check(reference)
|
||||
assert store.path(reference["digest"]).read_bytes() == b"\x89PNG..."
|
||||
|
||||
|
||||
def test_a_port_is_wanted_while_watched_or_read(monkeypatch):
|
||||
"""A camera fetches frames only while a screen shows them or a flow reads them."""
|
||||
from fluksio.flow.demand import demand
|
||||
|
||||
node = a_sensor([])
|
||||
# A worker process binds no controller and cannot see who watches.
|
||||
assert node.wanted("reading")
|
||||
|
||||
reads: set[str] = set()
|
||||
monkeypatch.setattr(
|
||||
demand, "_controller", SimpleNamespace(consumed_messages=lambda: reads)
|
||||
)
|
||||
assert not node.wanted("reading")
|
||||
|
||||
reads.add("demo.reading")
|
||||
assert node.wanted("reading")
|
||||
|
||||
reads.clear()
|
||||
demand.want("a viewer", {"demo.reading"})
|
||||
try:
|
||||
assert node.wanted("reading")
|
||||
finally:
|
||||
demand.drop("a viewer")
|
||||
assert not node.wanted("reading")
|
||||
|
||||
Reference in New Issue
Block a user