Coverage for src/lexigram/notification/cli/contributor.py: 0%

24 statements  

« prev     ^ index     » next       coverage.py v7.15.4, created at 2026-08-26 02:26 +0800

1"""Notification CLI contributor definitions.""" 

2 

3from __future__ import annotations 

4 

5from typing import Any 

6 

7from lexigram.contracts.cli.contributions import ( 

8 CommandContribution, 

9 DoctorCheckContribution, 

10 HealthCheckContribution, 

11 SchemaSetupContribution, 

12) 

13from lexigram.contracts.cli.types import GeneratorDefinition 

14 

15_GENERATOR_DEFINITIONS: tuple[GeneratorDefinition, ...] = ( 

16 GeneratorDefinition( 

17 name="notification_template", 

18 title="Generate Notification Template", 

19 description="Generate a notification template", 

20 contributor="notification", 

21 generator_path="lexigram.notification.cli.generators.template:NotificationTemplateGenerator", 

22 default_output_dir="src/notifications", 

23 category="notification", 

24 ), 

25) 

26 

27 

28class NotificationCliContributor: 

29 """CLI contributor for the lexigram-notification package.""" 

30 

31 @property 

32 def contributor_id(self) -> str: 

33 """Return the contributor identifier.""" 

34 return "notification" 

35 

36 def get_generators(self) -> list[GeneratorDefinition]: 

37 """Return generator definitions for notification.""" 

38 return list(_GENERATOR_DEFINITIONS) 

39 

40 def get_commands(self) -> list[CommandContribution]: 

41 """Return the contributed `notify` command group.""" 

42 return [ 

43 CommandContribution( 

44 name="notify", 

45 help="Notification channel management commands", 

46 app_factory_path="lexigram.notification.cli.commands:create_notify_app", 

47 contributor="notification", 

48 category="notification", 

49 requires_app_context=True, 

50 ), 

51 ] 

52 

53 def get_health_checks(self) -> list[HealthCheckContribution]: 

54 """Return notification channel health checks.""" 

55 return [ 

56 HealthCheckContribution( 

57 name="notification_channels", 

58 description="Check notification channels are reachable", 

59 check_path="lexigram.notification.cli.checks:check_notification_channels", 

60 contributor="notification", 

61 category="notification", 

62 timeout=15.0, 

63 ), 

64 ] 

65 

66 def get_doctor_checks(self) -> list[DoctorCheckContribution]: 

67 """Return notification configuration doctor checks.""" 

68 return [ 

69 DoctorCheckContribution( 

70 name="smtp_configured", 

71 description="Check SMTP configuration is present", 

72 check_path="lexigram.notification.cli.doctor:check_smtp_config", 

73 contributor="notification", 

74 category="notification", 

75 ), 

76 DoctorCheckContribution( 

77 name="push_credentials_configured", 

78 description="Check push notification credentials are configured", 

79 check_path="lexigram.notification.cli.doctor:check_push_credentials", 

80 contributor="notification", 

81 category="notification", 

82 ), 

83 ] 

84 

85 def get_shell_context(self) -> list[Any]: 

86 """Return no shell context contributions.""" 

87 return [] 

88 

89 def get_hooks(self) -> list[Any]: 

90 """Return no hook contributions.""" 

91 return [] 

92 

93 def get_schema_setup(self) -> list[SchemaSetupContribution]: 

94 """Return schema setup contributions for notification.""" 

95 return [ 

96 SchemaSetupContribution( 

97 name="notification.inbox_messages", 

98 description="In-app notification inbox storage", 

99 setup_fn_path="lexigram.notification.cli.schema_setup:ensure_inbox_messages", 

100 contributor=self.contributor_id, 

101 ), 

102 ] 

103 

104 

105__all__ = ["NotificationCliContributor"]