예제 #1
0
    def test_human_friendly_strings(self):
        """test human friendly outputs."""

        rang = TimeRange(EPOCH, EPOCH + datetime.timedelta(hours=24))

        # Hmmm, this is going to vary depending on where it is run.
        # self.assertEqual(rang.humanize(), 'Dec 31, 1969 04:00:00 PM to Jan 1, 1970 04:00:00 PM')

        rang = TimeRange.last_day()
        self.assertEqual(rang.relative_string(), 'a day ago to now')

        rang = TimeRange.last_seven_days()
        # due to the using UTC offsets, this date can appear to be either 6, 7, or 8 days ago
        # 6 for negative offsets, 7 for UTC, 8 for positive offsets
        # unless the local machine clock _happens_ to be set to UTC.
        self.assertTrue(rang.relative_string(
        ) in ['7 days ago to now', '6 days ago to now', '8 days ago to now'])

        rang = TimeRange.last_thirty_days()
        # this can return ambiguous results
        # self.assertEqual(rang.relative_string(), '30 days ago to now')

        rang = TimeRange.last_month()
        # this can return ambiguous results - might be 30 days ago, or a month ago
        # self.assertEqual(rang.relative_string(), 'a month ago to now')

        rang = TimeRange.last_ninety_days()
        self.assertEqual(rang.relative_string(), '2 months ago to now')
예제 #2
0
    def test_human_friendly_strings(self):
        """test human friendly outputs."""

        rang = TimeRange(EPOCH, EPOCH + datetime.timedelta(hours=24))

        # Hmmm, this is going to vary depending on where it is run.
        # self.assertEqual(rang.humanize(), 'Dec 31, 1969 04:00:00 PM to Jan 1, 1970 04:00:00 PM')

        rang = TimeRange.last_day()
        self.assertEqual(rang.relative_string(), 'a day ago to now')

        rang = TimeRange.last_seven_days()
        self.assertEqual(rang.relative_string(), '7 days ago to now')

        rang = TimeRange.last_thirty_days()
        # this can return ambiguous results
        # self.assertEqual(rang.relative_string(), '30 days ago to now')

        rang = TimeRange.last_month()
        # this can return ambiguous results - might be 30 days ago, or a month ago
        # self.assertEqual(rang.relative_string(), 'a month ago to now')

        rang = TimeRange.last_ninety_days()
        self.assertEqual(rang.relative_string(), '2 months ago to now')
예제 #3
0
파일: range_test.py 프로젝트: esnet/pypond
    def test_human_friendly_strings(self):
        """test human friendly outputs."""

        rang = TimeRange(EPOCH, EPOCH + datetime.timedelta(hours=24))

        # Hmmm, this is going to vary depending on where it is run.
        # self.assertEqual(rang.humanize(), 'Dec 31, 1969 04:00:00 PM to Jan 1, 1970 04:00:00 PM')

        rang = TimeRange.last_day()
        self.assertEqual(rang.relative_string(), 'a day ago to now')

        rang = TimeRange.last_seven_days()
        self.assertEqual(rang.relative_string(), '7 days ago to now')

        rang = TimeRange.last_thirty_days()
        # this can return ambiguous results
        # self.assertEqual(rang.relative_string(), '30 days ago to now')

        rang = TimeRange.last_month()
        # this can return ambiguous results - might be 30 days ago, or a month ago
        # self.assertEqual(rang.relative_string(), 'a month ago to now')

        rang = TimeRange.last_ninety_days()
        self.assertEqual(rang.relative_string(), '2 months ago to now')