- Moved all hookify configuration files from `.claude/` to `.claude/hooks/` subdirectory for better organization - Added four new blocking hooks to prevent common error handling anti-patterns: - `block-broad-exception-handler`: Prevents catching generic `Exception` with only logging - `block-datetime-now-fallback`: Blocks returning `datetime.now()` as fallback on parse failures to prevent data corruption - `block-default
111 lines
4.8 KiB
Python
111 lines
4.8 KiB
Python
"""Proto compilation and import verification tests.
|
|
|
|
Ensures proto stubs compile correctly and new Sprint 0 messages exist.
|
|
"""
|
|
|
|
|
|
class TestProtoImports:
|
|
"""Verify proto stubs import without errors."""
|
|
|
|
def test_proto_pb2_imports(self) -> None:
|
|
"""Proto message module imports cleanly."""
|
|
# Act & Assert: Import should not raise
|
|
from noteflow.grpc.proto import noteflow_pb2
|
|
|
|
assert noteflow_pb2 is not None, "noteflow_pb2 module should import"
|
|
|
|
def test_proto_pb2_grpc_imports(self) -> None:
|
|
"""Proto gRPC module imports cleanly."""
|
|
from noteflow.grpc.proto import noteflow_pb2_grpc
|
|
|
|
assert noteflow_pb2_grpc is not None, "noteflow_pb2_grpc module should import"
|
|
|
|
|
|
class TestSprint0Messages:
|
|
"""Verify Sprint 0 proto additions exist."""
|
|
|
|
def test_summarization_options_exists(self) -> None:
|
|
"""SummarizationOptions message exists (Sprint 1)."""
|
|
from noteflow.grpc.proto import noteflow_pb2
|
|
|
|
assert hasattr(noteflow_pb2, "SummarizationOptions"), "SummarizationOptions message missing"
|
|
opts = noteflow_pb2.SummarizationOptions()
|
|
assert opts.tone == "", "tone should default to empty string"
|
|
assert opts.format == "", "format should default to empty string"
|
|
assert opts.verbosity == "", "verbosity should default to empty string"
|
|
|
|
def test_generate_summary_request_has_options(self) -> None:
|
|
"""GenerateSummaryRequest has options field (Sprint 1)."""
|
|
from noteflow.grpc.proto import noteflow_pb2
|
|
|
|
request = noteflow_pb2.GenerateSummaryRequest()
|
|
assert hasattr(request, "options"), "options field missing from GenerateSummaryRequest"
|
|
|
|
def test_extract_entities_messages_exist(self) -> None:
|
|
"""NER messages exist (Sprint 4)."""
|
|
from noteflow.grpc.proto import noteflow_pb2
|
|
|
|
assert hasattr(noteflow_pb2, "ExtractEntitiesRequest"), "ExtractEntitiesRequest missing"
|
|
assert hasattr(noteflow_pb2, "ExtractEntitiesResponse"), "ExtractEntitiesResponse missing"
|
|
assert hasattr(noteflow_pb2, "ExtractedEntity"), "ExtractedEntity missing"
|
|
|
|
entity = noteflow_pb2.ExtractedEntity()
|
|
assert entity.confidence == 0.0, "confidence should default to 0.0"
|
|
assert entity.is_pinned is False, "is_pinned should default to False"
|
|
|
|
def test_calendar_messages_exist(self) -> None:
|
|
"""Calendar messages exist (Sprint 5)."""
|
|
from noteflow.grpc.proto import noteflow_pb2
|
|
|
|
assert hasattr(noteflow_pb2, "CalendarEvent"), "CalendarEvent missing"
|
|
assert hasattr(noteflow_pb2, "CalendarProvider"), "CalendarProvider missing"
|
|
assert hasattr(noteflow_pb2, "ListCalendarEventsRequest"), (
|
|
"ListCalendarEventsRequest missing"
|
|
)
|
|
assert hasattr(noteflow_pb2, "ListCalendarEventsResponse"), (
|
|
"ListCalendarEventsResponse missing"
|
|
)
|
|
assert hasattr(noteflow_pb2, "GetCalendarProvidersRequest"), (
|
|
"GetCalendarProvidersRequest missing"
|
|
)
|
|
assert hasattr(noteflow_pb2, "GetCalendarProvidersResponse"), (
|
|
"GetCalendarProvidersResponse missing"
|
|
)
|
|
|
|
def test_export_format_pdf_exists(self) -> None:
|
|
"""EXPORT_FORMAT_PDF enum value exists (Sprint 3)."""
|
|
from noteflow.grpc.proto import noteflow_pb2
|
|
|
|
assert hasattr(noteflow_pb2, "EXPORT_FORMAT_PDF"), "EXPORT_FORMAT_PDF enum missing"
|
|
assert isinstance(noteflow_pb2.EXPORT_FORMAT_PDF, int), "EXPORT_FORMAT_PDF should be int"
|
|
|
|
|
|
class TestSprint0RPCs:
|
|
"""Verify Sprint 0 RPC stubs exist."""
|
|
|
|
def test_servicer_has_extract_entities(self) -> None:
|
|
"""NoteFlowServicer has ExtractEntities method on stub."""
|
|
from noteflow.grpc.proto import noteflow_pb2_grpc
|
|
|
|
servicer = noteflow_pb2_grpc.NoteFlowServiceServicer
|
|
assert hasattr(servicer, "ExtractEntities"), "ExtractEntities RPC missing"
|
|
|
|
def test_servicer_has_calendar_rpcs(self) -> None:
|
|
"""NoteFlowServicer has calendar RPCs."""
|
|
from noteflow.grpc.proto import noteflow_pb2_grpc
|
|
|
|
servicer = noteflow_pb2_grpc.NoteFlowServiceServicer
|
|
assert hasattr(servicer, "ListCalendarEvents"), "ListCalendarEvents RPC missing"
|
|
assert hasattr(servicer, "GetCalendarProviders"), "GetCalendarProviders RPC missing"
|
|
|
|
def test_stub_rpc_methods_in_init(self) -> None:
|
|
"""NoteFlowServiceStub __init__ assigns expected RPC methods."""
|
|
import inspect
|
|
|
|
from noteflow.grpc.proto import noteflow_pb2_grpc
|
|
|
|
source = inspect.getsource(noteflow_pb2_grpc.NoteFlowServiceStub.__init__)
|
|
assert "self.ExtractEntities" in source, "ExtractEntities stub missing"
|
|
assert "self.ListCalendarEvents" in source, "ListCalendarEvents stub missing"
|
|
assert "self.GetCalendarProviders" in source, "GetCalendarProviders stub missing"
|