Example #1
0
    def test_single_day_is_24_hours(self):
        values = get_day_data(self.account, date(2011, 1, 1))

        td = values['to_date'] - values['from_date']
        days, hours, minutes = td.days, td.seconds // 3600, td.seconds // 60 % 60

        assert(days == 0)
        assert(hours == 23)
        assert(minutes == 59)
Example #2
0
    def test_day_in_the_past(self):
        day = date(2011, 2, 22)
        values = get_day_data(self.account, day)

        from_date = datetime(hour=0, minute=0, day=day.day, year=day.year, month=day.month).replace(
            tzinfo=self.account.tz)
        to_date = datetime(hour=23, minute=59, second=59, day=day.day, year=day.year, month=day.month).replace(
            tzinfo=self.account.tz)

        assert from_date == values['from_date']
        assert to_date == values['to_date']
        assert from_date == values['target_day']
        assert from_date == values['display_date']
        assert values['previous_date_url'] == "/day/21/02/2011"
        assert values['next_date_url'] == "/day/23/02/2011"
Example #3
0
    def test_today(self):
        """ Test that getting the current day will
        return the correct dates including a
        none for the next day """

        today = datetime.utcnow().replace(tzinfo=pytz.utc).astimezone(self.account.tz)
        day = datetime(hour=18, minute=0, day=today.day, year=today.year, month=today.month).replace(tzinfo=self.account.tz)
        yesterday = day - timedelta(days=1)
        
        from_date = datetime(hour=0, minute=0, day=day.day, year=day.year, month=day.month).replace(
            tzinfo=self.account.tz)
        to_date = datetime(hour=23, minute=59, second=59, day=day.day, year=day.year, month=day.month).replace(
            tzinfo=self.account.tz)

        values = get_day_data(self.account, day)

        assert from_date == values['from_date']
        assert to_date == values['to_date']
        assert from_date == values['target_day']
        assert from_date == values['display_date']
        assert values['previous_date_url'] == strftime("/day/%d/%m/%Y", yesterday.timetuple())
        assert values['next_date_url'] is None