def test_build_sub_comment__image_oc_all_enabled(self): response_builder = ResponseBuilder(MagicMock()) search_results = self._get_image_search_results_no_match() result = response_builder.build_sub_comment(self._get_monitored_sub(), search_results, signature=True, stats=True, search_link=True, search_settings=True) self.assertEqual(IMAGE_OC_SUBREDDIT_CUSTOM, result)
def test_build_default_comment__link_repost_all_enabled(self): response_builder = ResponseBuilder(MagicMock()) search_results = self._get_link_search_results_matches_match() result = response_builder.build_default_comment(search_results, signature=True, stats=True, search_link=True, search_settings=True) self.assertEqual(LINK_REPOST_ALL_ENABLED, result)
def test_build_default_comment__image_oc_all_enabled_close_match(self): response_builder = ResponseBuilder(MagicMock()) search_results = self._get_image_search_results_no_match() search_results.closest_match = ImageSearchMatch('test.com', 1, Post(post_id='abc123', created_at=datetime.strptime( '2019-01-28 05:20:03', '%Y-%m-%d %H:%M:%S')), 5, 3, 32) result = response_builder.build_default_comment(search_results, signature=True, stats=True, search_link=True, search_settings=True) self.assertEqual(IMAGE_OC_ALL_ENABLED_ALL_ENABLED_NO_MEME, result)
def __init__(self): self.config = Config() self.redlock = get_redlock_factory(self.config) self.reddit = get_reddit_instance(self.config) self.reddit_manager = RedditManager(self.reddit) self.uowm = SqlAlchemyUnitOfWorkManager(get_db_engine(self.config)) self.event_logger = EventLogging(config=self.config) notification_svc = NotificationService(self.config) self.response_handler = ResponseHandler( self.reddit_manager, self.uowm, self.event_logger, source='summons', live_response=self.config.live_responses, notification_svc=notification_svc) dup_image_svc = DuplicateImageService(self.uowm, self.event_logger, self.reddit, config=self.config) response_builder = ResponseBuilder(self.uowm) self.summons_handler = SummonsHandler( self.uowm, dup_image_svc, self.reddit_manager, response_builder, self.response_handler, event_logger=self.event_logger, summons_disabled=False, notification_svc=notification_svc)
def __init__(self): self.config = Config() self.reddit = get_reddit_instance(self.config) self.reddit_manager = RedditManager(self.reddit) self.uowm = SqlAlchemyUnitOfWorkManager(get_db_engine(self.config)) event_logger = EventLogging(config=self.config) response_handler = ResponseHandler( self.reddit_manager, self.uowm, event_logger, source='submonitor', live_response=self.config.live_responses) dup_image_svc = DuplicateImageService(self.uowm, event_logger, self.reddit, config=self.config) response_builder = ResponseBuilder(self.uowm) self.sub_monitor = SubMonitor(dup_image_svc, self.uowm, self.reddit_manager, response_builder, response_handler, event_logger=event_logger, config=self.config)
from redditrepostsleuth.core.services.eventlogging import EventLogging from redditrepostsleuth.core.services.reddit_manager import RedditManager from redditrepostsleuth.core.services.response_handler import ResponseHandler from redditrepostsleuth.core.db.db_utils import get_db_engine from redditrepostsleuth.core.db.uow.sqlalchemyunitofworkmanager import SqlAlchemyUnitOfWorkManager from redditrepostsleuth.core.services.responsebuilder import ResponseBuilder from redditrepostsleuth.core.util.helpers import get_reddit_instance, get_redis_client from redditrepostsleuth.core.services.duplicateimageservice import DuplicateImageService from redditrepostsleuth.submonitorsvc.submonitor import SubMonitor if __name__ == '__main__': config = Config() event_logger = EventLogging(config=config) uowm = SqlAlchemyUnitOfWorkManager(get_db_engine(config)) response_builder = ResponseBuilder(uowm) reddit = get_reddit_instance(config) reddit_manager = RedditManager(reddit) dup = DuplicateImageService(uowm, event_logger, reddit, config=config) monitor = SubMonitor(dup, uowm, reddit_manager, response_builder, ResponseHandler(reddit_manager, uowm, event_logger, source='submonitor', live_response=config.live_responses), event_logger=event_logger, config=config) redis = get_redis_client(config)
def test_build_default_comment__image_repost_multi_match_all_enabled(self): response_builder = ResponseBuilder(MagicMock()) search_results = self._get_image_search_results_multi_match() result = response_builder.build_default_comment(search_results, signature=True, stats=True, search_link=True, search_settings=True) self.assertEqual(IMAGE_REPOST_MULTI_MATCH_ALL_ENABLED, result)
def test_build_default_comment__image_oc_only_search_settings(self): response_builder = ResponseBuilder(MagicMock()) search_results = self._get_image_search_results_no_match() result = response_builder.build_default_comment(search_results, signature=False, stats=False, search_link=False, search_settings=True) self.assertEqual(IMAGE_OC_ONLY_SEARCH_SETTINGS, result)
def test_build_default_comment__image_oc_no_sig_or_stat_or_search_link(self): response_builder = ResponseBuilder(MagicMock()) search_results = self._get_image_search_results_no_match() result = response_builder.build_default_comment(search_results, signature=False, stats=False, search_link=False, search_settings=False) self.assertEqual(IMAGE_OC_NO_CLOSE_NO_SIG_NO_STATS_NO_SEARCH, result)