def lambda_handler(event, context): # TODO handle what happens if there's not an existing thread try: time_string = event["body"]["time"] validate = event["body"]["validate"] except KeyError: main(reddit=get_datascience_bot(), subreddit_name=SUBREDDIT_NAME) else: time = datetime.strptime(time_string, "%Y-%m-%d") main( reddit=get_datascience_bot(), subreddit_name=SUBREDDIT_NAME, time=time, validate=validate, ) return "200 OK"
def setUp(self): self.alex = get_SubstantialStrain6() self.bobby = get_datascience_bot() self.charlie = get_b3405920() self.bots = [self.alex, self.bobby, self.charlie] print(">>> Set up tests", "-" * 60) self.delete_existing_submissions() self.delete_existing_comments() print("<<< Set up tests", "-" * 60)
# -*- coding: utf-8 -*- """Mod Tools: Removal Reasons """ import argparse import logging from libs.shared.authpraw import get_datascience_bot from libs.modtools.site_admin import update_settings import libs.shared.logging libs.shared.logging.basicConfig() logger = logging.getLogger(__name__) ARGS = argparse.ArgumentParser(description="Update the removal reasons on a subreddit") ARGS.add_argument( "subreddit_name", metavar="subreddit_name", type=str, help="Subreddit removal reasons to update", ) if __name__ == "__main__": args = ARGS.parse_args() bobby = get_datascience_bot() subreddit = bobby.subreddit(args.subreddit_name) update_settings(subreddit=subreddit)
def lambda_handler(event, context): bobby = get_datascience_bot() subreddit_name = os.getenv("SUBREDDIT_NAME") subreddit = bobby.subreddit(subreddit_name) main(subreddit=subreddit)
def test_get_datascience_bot(self): redditor = get_datascience_bot() self.assertEqual(redditor.user.me(), "datascience-bot")
help="Subreddit to act on", ) ARGS.add_argument( "--fake-sunday", dest="fake_sunday", action="store_true", help="Whether to fake a Sunday on Sun, 7 Jul 2019", ) ARGS.add_argument( "--no-validate", dest="no_validate", action="store_true", help="Whether validate prerequisite conditions", ) if __name__ == "__main__": args = ARGS.parse_args() if args.fake_sunday is True: time = datetime.strptime("2019-07-07", "%Y-%m-%d") else: time = datetime.utcnow() main( reddit=get_datascience_bot(), subreddit_name=args.subreddit_name, time=time, validate=not args.no_validate, )
def setUp(self, monitor_constructor): bobby = get_datascience_bot() subreddit = bobby.subreddit("datascience_bot_dev") self.monitor = monitor_constructor(subreddit)