Adds RedditCommentStrategy to app/services/platforms/reddit_comment.py, resolving thread_id via thread_url_override or _find_sticky title search, falling back to reconstructed URL when client.comment() returns empty string. Registers the strategy under "reddit_comment" in the platform _REGISTRY. 7 new tests confirm all execution paths: url override, title pattern lookup, not-found error, missing-extra error, empty-URL reconstruction, dupe guard, and registry presence. Full suite: 34/34 passing.
29 lines
899 B
Python
29 lines
899 B
Python
from __future__ import annotations
|
|
|
|
from app.services.platforms.base import PostingStrategy, PostResult
|
|
from app.services.platforms.reddit_post import RedditPostStrategy
|
|
from app.services.platforms.reddit_comment import RedditCommentStrategy
|
|
|
|
_REGISTRY: dict[str, PostingStrategy] = {
|
|
s.campaign_type: s()
|
|
for s in [
|
|
RedditPostStrategy,
|
|
RedditCommentStrategy,
|
|
# BlogPostStrategy — added in Plan C
|
|
]
|
|
}
|
|
|
|
SUPPORTED_PLATFORMS: frozenset[str] = frozenset(_REGISTRY)
|
|
|
|
|
|
def get_client(campaign_type: str) -> PostingStrategy:
|
|
"""Return the strategy instance for the given campaign type.
|
|
|
|
Raises ValueError for unknown types.
|
|
"""
|
|
if campaign_type not in _REGISTRY:
|
|
raise ValueError(f"Unknown campaign type: {campaign_type!r}")
|
|
return _REGISTRY[campaign_type]
|
|
|
|
|
|
__all__ = ["get_client", "SUPPORTED_PLATFORMS", "PostingStrategy", "PostResult"]
|