<s> from __future__ import absolute_import <EOL> import pytz <EOL> from datetime import datetime , timedelta <EOL> from sentry . testutils import TestCase <EOL> from sentry . tsdb . base import BaseTSDB , ONE_MINUTE , ONE_HOUR , ONE_DAY <EOL> class BaseTSDBTest ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . tsdb = BaseTSDB ( rollups = ( <EOL> ( <NUM_LIT:10> , <NUM_LIT:30> ) , <EOL> ( ONE_MINUTE , <NUM_LIT> ) , <EOL> ( ONE_HOUR , <NUM_LIT> ) , <EOL> ( ONE_DAY , <NUM_LIT:30> ) , <EOL> ) ) <EOL> def test_normalize_to_epoch ( self ) : <EOL> timestamp = datetime ( <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT> , <NUM_LIT:15> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . UTC ) <EOL> normalize_to_epoch = self . tsdb . normalize_to_epoch <EOL> result = normalize_to_epoch ( timestamp , <NUM_LIT> ) <EOL> assert result == <NUM_LIT> <EOL> result = normalize_to_epoch ( timestamp + timedelta ( seconds = <NUM_LIT:20> ) , <NUM_LIT> ) <EOL> assert result == <NUM_LIT> <EOL> result = normalize_to_epoch ( timestamp + timedelta ( seconds = <NUM_LIT:30> ) , <NUM_LIT> ) <EOL> assert result == <NUM_LIT> <EOL> result = normalize_to_epoch ( timestamp + timedelta ( seconds = <NUM_LIT> ) , <NUM_LIT> ) <EOL> assert result == <NUM_LIT> <EOL> def test_rollup ( self ) : <EOL> pre_results = { <EOL> <NUM_LIT:1> : [ ( <NUM_LIT> , <NUM_LIT:5> ) , ( <NUM_LIT> , <NUM_LIT:10> ) , ( <NUM_LIT> , <NUM_LIT:7> ) ] , <EOL> } <EOL> post_results = self . tsdb . rollup ( pre_results , <NUM_LIT> ) <EOL> assert len ( post_results ) == <NUM_LIT:1> <EOL> assert post_results [ <NUM_LIT:1> ] == [ <EOL> [ <NUM_LIT> , <NUM_LIT:15> ] , [ <NUM_LIT> , <NUM_LIT:7> ] <EOL> ] <EOL> def test_calculate_expiry ( self ) : <EOL> timestamp = datetime ( <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT> , <NUM_LIT:15> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . UTC ) <EOL> result = self . tsdb . calculate_expiry ( <NUM_LIT:10> , <NUM_LIT:30> , timestamp ) <EOL> assert result == <NUM_LIT> </s>
