def delete_submissions(self, job): r = get_reddit_instance(refresh_token=job.refresh_token) submissions = r.user.me().submissions.new(limit=REDDIT_QUERY_LIMIT) logger.info("Step: Processing submissions") for submission in submissions: if submission.created_utc < calendar.timegm(job.started.utctimetuple()): job.submissions_deleted = job.submissions_deleted + 1 if can_delete_content(): submission.delete() else: logger.info("Not deleting. As this has not been enabled.") break else: logger.info("No submissions within timeframe") job.state = Job.STATE_FINISHED job.save()
def delete_comments(self, job): r = get_reddit_instance(refresh_token=job.refresh_token) comments = r.user.me().comments.new(limit=REDDIT_QUERY_LIMIT) logger.info("Step: Processing comments") for comment in comments: if comment.created_utc < calendar.timegm(job.started.utctimetuple()): job.comments_deleted = job.comments_deleted + 1 if can_delete_content(): comment.delete() else: logger.info("Not deleting. As this has not been enabled.") break else: logger.info("No comments within timeframe") job.state = Job.STATE_DELETING_SUBMISSIONS job.save()
def test_enabled(self): result = can_delete_content() self.assertTrue(result)
def test_false_setting_not_set_to_deleting_content(self): result = can_delete_content() self.assertFalse(result)
def test_false_in_development(self): result = can_delete_content() self.assertFalse(result)
def test_returns_boolean(self): result = can_delete_content() self.assertIsInstance(result, bool)