def test_add_cakeday_exists(database, reddit): username = "******" created = utils.parse_datetime_string("2015-05-05 15:25:17") user = reddit_test.User(username, created.timestamp()) message = reddit_test.RedditObject(body="Cakeday!", author=user) messages.process_message(message, reddit, database) message2 = reddit_test.RedditObject(body="Cakeday!", author=user) messages.process_message(message2, reddit, database) result = message2.get_first_child().body assert "It looks like you already have a cakeday reminder set." in result
def test_add_cakeday(database, reddit): username = "******" created = utils.parse_datetime_string("2015-05-05 15:25:17") user = reddit_test.User(username, created.timestamp()) message = reddit_test.RedditObject(body="Cakeday!", author=user) utils.debug_time = utils.parse_datetime_string("2019-01-05 12:00:00") messages.process_message(message, reddit, database) result = message.get_first_child().body assert "to remind you of your cakeday" in result cakeday = database.get_cakeday(username) assert cakeday is not None assert cakeday.user == username assert cakeday.date_time == utils.parse_datetime_string( "2019-05-05 15:25:17") assert cakeday.db_id is not None
def test_add_cakeday(database, reddit): username = "******" created = utils.parse_datetime_string("2015-05-05 15:25:17") user = reddit_test.User(username, created.timestamp()) message = reddit_test.RedditObject(body="Cakeday!", author=user) utils.debug_time = utils.parse_datetime_string("2019-01-05 12:00:00") messages.process_message(message, reddit, database) result = message.get_first_child().body assert "to remind you of your cakeday" in result reminders = database.get_all_user_reminders(username) assert len(reminders) == 1 assert reminders[0].user.name == username assert reminders[0].target_date == utils.parse_datetime_string( "2019-05-05 15:25:17") assert reminders[0].id is not None assert reminders[0].recurrence == "1 year" assert reminders[0].message == "Happy Cakeday!"
def test_process_cakeday_comment(database, reddit): username = "******" user = reddit_test.User( username, utils.parse_datetime_string("2015-05-05 15:25:17").timestamp()) reddit.add_user(user) created = utils.parse_datetime_string("2019-01-05 11:00:00") comment_id = utils.random_id() thread_id = utils.random_id() comment = reddit_test.RedditObject( body=f"{static.TRIGGER_CAKEDAY}!", author=username, created=created, id=comment_id, link_id="t3_" + thread_id, permalink=f"/r/test/{thread_id}/_/{comment_id}/", subreddit="test") reddit.add_comment(comment) utils.debug_time = utils.parse_datetime_string("2019-01-05 12:00:00") comments.process_comment(comment.get_pushshift_dict(), reddit, database) result = comment.get_first_child().body assert "to remind you of your cakeday" in result reminders = database.get_all_user_reminders(username) assert len(reminders) == 1 assert reminders[0].user.name == username assert reminders[0].source == utils.reddit_link(comment.permalink) assert reminders[0].requested_date == created assert reminders[0].target_date == utils.parse_datetime_string( "2019-05-05 15:25:17") assert reminders[0].id is not None assert reminders[0].recurrence == "1 year" assert reminders[0].message == "Happy Cakeday!"