Beispiel #1
0
    def test_is_time_daily(self):
        interval_min = 40
        now = datetime.datetime.now()

        send_time_date = now + datetime.timedelta(minutes=interval_min - 1)
        send_time = send_time_date.time()
        dict_sample_config = {
                "interval_min": interval_min,
                "daily_send_hour": send_time,
                "weekly_send_hour": send_time,
                "weekly_send_day": 4,
                }
        expected_result = True
        pintrck = Pintracker(dict_sample_config)
        actual_result = pintrck.is_time_daily()
        self.assertEqual(actual_result, expected_result)

        send_time_date = now - datetime.timedelta(minutes=interval_min + 1)
        send_time = send_time_date.time()
        dict_sample_config = {
                "interval_min": interval_min,
                "daily_send_hour": send_time,
                "weekly_send_hour": send_time,
                "weekly_send_day": 4,
                }
        expected_result = False
        pintrck = Pintracker(dict_sample_config)
        actual_result = pintrck.is_time_daily()
        self.assertEqual(actual_result, expected_result)