Coverage for src / rtflite / pagination / strategies / registry.py: 86%

14 statements  

« prev     ^ index     » next       coverage.py v7.12.0, created at 2025-12-08 04:50 +0000

1from .base import PaginationStrategy 

2 

3 

4class StrategyRegistry: 

5 """Registry for pagination strategies.""" 

6 

7 _strategies: dict[str, type[PaginationStrategy]] = {} 

8 

9 @classmethod 

10 def register(cls, name: str, strategy_cls: type[PaginationStrategy]) -> None: 

11 """Register a new strategy.""" 

12 cls._strategies[name] = strategy_cls 

13 

14 @classmethod 

15 def get(cls, name: str) -> type[PaginationStrategy]: 

16 """Get a strategy by name.""" 

17 if name not in cls._strategies: 

18 raise ValueError(f"Strategy '{name}' not found in registry.") 

19 return cls._strategies[name] 

20 

21 @classmethod 

22 def list_strategies(cls) -> list[str]: 

23 """List all registered strategies.""" 

24 return list(cls._strategies.keys())