def test_sub_privated_allowed(self): reddit = praw.Reddit(username=credentials['reddit']['username']) global last_switcharoo last_switcharoo = reset_database(reddit, last_switcharoo) last_switcharoo.update_privated_sub("sub2", allowed=True, update_requested=False) previous_roo, previous_url, previous_submission = gen_url_and_roo( reddit, last_switcharoo, "sub1", "user1", "000000", "aaaaaa", "123abcd", 3, datetime(month=4, day=1, year=2021)) roo, url, submission = gen_url_and_roo( reddit, last_switcharoo, "sub2", "user1", "000001", "aaaaab", "123abce", 3, datetime(month=4, day=2, year=2021)) reddit.submission("aaaaab").private = True reddit.comment("123abce", f"[Ah the ol' Reddit switcharoo!]({previous_url})", "user1", datetime(month=4, day=2, year=2020), private=True) tracker = check_errors(reddit, last_switcharoo, roo, init_db=False, submission=submission) self.assertTrue(tracker is None)
def test_normal(self): reddit = praw.Reddit(username=credentials['reddit']['username']) global last_switcharoo last_switcharoo = reset_database(reddit, last_switcharoo) previous_roo, previous_url, previous_submission = gen_url_and_roo( reddit, last_switcharoo, "sub1", "user1", "000000", "aaaaaa", "123abcd", 3, datetime(month=4, day=1, year=2021)) roo, url, submission = gen_url_and_roo(reddit, last_switcharoo, "sub1", "user1", "000001", "aaaaab", "123abce", 3, datetime(month=4, day=2, year=2021), init_db=True) reddit.comment("123abce", f"[Ah the ol' Reddit switcharoo!]({previous_url})", "user1", datetime(month=4, day=2, year=2020)) expected_tracker = IssueTracker() tracker = check_errors(reddit, last_switcharoo, roo, init_db=True, submission=submission) self.assertTrue(tracker == expected_tracker)
def test_too_new_to_fix_flair(self): reddit = praw.Reddit(username=credentials['reddit']['username']) global last_switcharoo last_switcharoo = reset_database(reddit, last_switcharoo) roo, url, submission = gen_url_and_roo(reddit, last_switcharoo, "sub1", "user1", "000001", "aaaaab", "123abce", 3, datetime.now()) roo = last_switcharoo.search(comment_id="123abce") reply_object = ReplyObject.from_roo(roo) increment_user_fixes(last_switcharoo, reply_object) f = last_switcharoo.check_user_flair(roo.user) if f: self.assertEqual(f.fixes, 0) else: self.assertEqual(f, None)