def test_first_month_of_2011_is_31_days(self): values = get_month_data(self.account, 1, 2011) td = values['to_date'] - values['from_date'] days, hours, minutes = td.days, td.seconds // 3600, td.seconds // 60 % 60 assert(days == 30) assert(hours == 23) assert(minutes == 59)
def test_month_in_the_past(self): values = get_month_data(self.account, "1", "2011") from_date = datetime(hour=0, minute=0, day=1, year=2011, month=1).replace(tzinfo=self.account.tz) to_date = datetime(hour=23, minute=59, day=31, year=2011, month=1).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'] == "/month/12/2010" assert values['next_date_url'] == "/month/02/2011"
def test_today(self): today = datetime.date(datetime.now()) month = today.month year = today.year values = get_month_data(self.account, month, year) days_in_month = monthrange(int(year), int(month))[1] from_date = datetime(hour=0, minute=0, day=1, year=int(year), month=int(month)).replace(tzinfo=self.account.tz) to_date = datetime(hour=23, minute=59, day=days_in_month, year=int(year), month=int(month)).replace( tzinfo=self.account.tz) a_day = timedelta(days=1) previous_date = from_date - a_day previous_date_url = strftime("/month/%m/%Y", previous_date.timetuple()) 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'] == previous_date_url assert values['next_date_url'] is None