Exemplo n.º 1
0
    def test_does_not_publish_reminder_when_reminder_date_is_not_today(
            self, reminder, mock_tweepy):
        with freeze_time("2020-12-14T15:32:00Z"):
            bot.publish_reminders()

        mock_tweepy.assert_not_called()
        assert Reminder().get_by_id(reminder.id).is_finished is False
Exemplo n.º 2
0
    def test_publishes_reminder_when_reminder_date_is_today_and_stock_went_up(
            self, reminder, mock_tweepy):
        with freeze_time(reminder.remind_on):
            bot.publish_reminders()

        expected_calls = [
            call().media_upload(filename=const.MR_SCROOGE_IMAGE_PATH),
            call().update_status(
                status="@user_name 3 months ago you bought $AMZN at $2,954.91. "
                "It is now worth $3,112.70. That's a return of 5.34%! 🚀🤑📈",
                media_ids=[ANY],
                in_reply_to_status_id=1,
            ),
        ]

        assert expected_calls in mock_tweepy.mock_calls
        assert Reminder().get_by_id(reminder.id).is_finished is True
Exemplo n.º 3
0
    def test_publishes_reminder_when_reminder_date_is_today_and_stock_went_down(
            self, reminder, mock_tweepy):
        reminder.stock_price = 3386.12
        reminder.save()
        with freeze_time(reminder.remind_on):
            bot.publish_reminders()

        expected_calls = [
            call().media_upload(filename=const.MR_BURNS_IMAGE_PATH),
            call().update_status(
                status="@user_name 3 months ago you bought $AMZN at $3,386.12. "
                "It is now worth $3,112.70. That's a return of -8.07%! 😭📉",
                media_ids=[ANY],
                in_reply_to_status_id=1,
            ),
        ]

        assert expected_calls in mock_tweepy.mock_calls
        assert Reminder().get_by_id(reminder.id).is_finished is True
Exemplo n.º 4
0
    def test_publishes_reminder_when_reminder_date_is_today_and_stock_was_split(
            self, reminder, mock_tweepy):
        reminder.created_on = date(2020, 8, 1)
        reminder.remind_on = datetime(2020, 12, 27, 12, 0)
        reminder.stock_symbol = "TSLA"
        reminder.stock_price = 2186.27
        reminder.save()

        with freeze_time(reminder.remind_on):
            bot.publish_reminders()

        expected_calls = [
            call().media_upload(filename=const.MR_SCROOGE_IMAGE_PATH),
            call().update_status(
                status="@user_name 4 months ago you bought $TSLA at $2,186.27 "
                "($437.25 after adjusting for the stock split). It is "
                "now worth $661.70. That's a return of 51.33%! 🚀🤑📈",
                media_ids=[ANY],
                in_reply_to_status_id=1,
            ),
        ]

        assert expected_calls in mock_tweepy.mock_calls
        assert Reminder().get_by_id(reminder.id).is_finished is True