Beispiel #1
0
    def test_should_build_utc_based_row_key_for_hourly_using_timezone_aware_datetime(self):

        # Both should generate the same row key
        utc_now = datetime.utcnow()
        local_now = datetime.now(tz=pytz.timezone('US/Eastern'))

        dto = TimestampedDataDTO('test', local_now, 'd', '0')
        row_key_local_now = dto.get_row_key_for_hourly()

        dto = TimestampedDataDTO('test', utc_now, 'd', '0')
        row_key_utc_now = dto.get_row_key_for_hourly()

        self.assertEqual(row_key_utc_now, row_key_local_now)
Beispiel #2
0
    def test_should_build_utc_based_row_key_for_hourly_using_timezone_aware_datetime(
            self):

        # Both should generate the same row key
        utc_now = datetime.utcnow()
        local_now = datetime.now(tz=pytz.timezone('US/Eastern'))

        dto = TimestampedDataDTO('test', local_now, 'd', '0')
        row_key_local_now = dto.get_row_key_for_hourly()

        dto = TimestampedDataDTO('test', utc_now, 'd', '0')
        row_key_utc_now = dto.get_row_key_for_hourly()

        self.assertEqual(row_key_utc_now, row_key_local_now)
Beispiel #3
0
    def test_should_print_row_key_for_hourly_using_naive_datetime(self):

        # returns naive datetime in the local timezone (ie. no timezone info)
        naive_local_now = datetime.now()
        utc_now = datetime.utcnow()

        dto = TimestampedDataDTO('test', naive_local_now, 'd', '0')

        row_key = dto.get_row_key_for_hourly()

        print row_key
Beispiel #4
0
    def test_should_print_row_key_for_hourly_using_naive_datetime(self):

        # returns naive datetime in the local timezone (ie. no timezone info)
        naive_local_now = datetime.now()
        utc_now = datetime.utcnow()

        dto = TimestampedDataDTO('test', naive_local_now, 'd', '0')

        row_key = dto.get_row_key_for_hourly()

        print row_key