Skip to content

Commit c1a659c

Browse files
committed
test: skip to_property_value tests when proto stubs absent
@_requires_proto on TestToPropertyValue — skips gracefully without make proto. TestFromPropertyValue (mock-based) always runs: 7 passed. Part of #1
1 parent afc7e8b commit c1a659c

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

tests/unit/test_types.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
1-
"""Unit tests for _types.py — PropertyValue conversion round-trips."""
1+
"""Unit tests for _types.py — PropertyValue conversion round-trips.
2+
3+
TestFromPropertyValue: pure mock-based, runs without proto stubs.
4+
TestToPropertyValue: requires generated proto stubs (make proto).
5+
Tests are skipped automatically when stubs are absent.
6+
"""
27

38
import pytest
49

510
from coordinode._types import from_property_value, to_property_value
611

12+
# Detect whether proto stubs have been generated.
13+
try:
14+
from coordinode._proto.coordinode.v1.common.types_pb2 import PropertyValue # noqa: F401
15+
_HAS_PROTO = True
16+
except ImportError:
17+
_HAS_PROTO = False
18+
19+
_requires_proto = pytest.mark.skipif(
20+
not _HAS_PROTO,
21+
reason="Proto stubs not generated — run `make proto` first",
22+
)
23+
724

825
class _FakeVec:
926
"""Minimal PropertyValue.vector stub."""
@@ -67,6 +84,7 @@ def map_value(self):
6784

6885
# ── to_property_value ───────────────────────────────────────────────────────
6986

87+
@_requires_proto
7088
class TestToPropertyValue:
7189
def test_int(self):
7290
pv = to_property_value(42)

0 commit comments

Comments
 (0)