Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add event helper

  • Loading branch information...
commit 75a927f6c4aaf59787b21a569cb23a35a3897c83 1 parent a740cc5
@tsileo authored
View
3  cube/__init__.py
@@ -93,4 +93,7 @@ def types(self):
return r.json()
def get_event(self, event_type):
+ """
+ Shortcut to initialize an Event object
+ """
return Event(self, event_type)
View
3  cube/event.py
@@ -3,6 +3,9 @@
class Event(object):
+ """ Cube instance that hold an event_type,
+ with shortcut for getting/creating events/metrics,
+ and creating expression. """
def __init__(self, cube, event_type):
self.cube = cube
self.event_type = event_type
View
18 cube/tests/test_time_utils.py
@@ -19,29 +19,29 @@ def setUp(self):
def test_yesterday(self):
self.assertEqual(time_utils.yesterday(self.now),
- datetime(2012, 7, 5, 20, 33, 16, 573225))
+ datetime(2012, 7, 5, 20, 33, 16, 573225))
def test_last_week(self):
self.assertEqual(time_utils.last_week(self.now),
- datetime(2012, 6, 29, 20, 33, 16, 573225))
+ datetime(2012, 6, 29, 20, 33, 16, 573225))
def test_start_of_month(self):
self.assertEqual(time_utils.start_of_month(self.now),
- datetime(2012, 7, 1))
+ datetime(2012, 7, 1))
def test_floor(self):
self.assertEqual(time_utils.floor(self.now, time_utils.STEP_10_SEC),
- datetime(2012, 7, 6, 20, 33, 10))
+ datetime(2012, 7, 6, 20, 33, 10))
self.assertEqual(time_utils.floor(self.now, time_utils.STEP_1_MIN),
- datetime(2012, 7, 6, 20, 33))
+ datetime(2012, 7, 6, 20, 33))
self.assertEqual(time_utils.floor(self.now, time_utils.STEP_5_MIN),
- datetime(2012, 7, 6, 20, 30))
+ datetime(2012, 7, 6, 20, 30))
self.assertEqual(time_utils.floor(self.now, time_utils.STEP_1_HOUR),
- datetime(2012, 7, 6, 20))
+ datetime(2012, 7, 6, 20))
self.assertEqual(time_utils.floor(self.now, time_utils.STEP_1_DAY),
- datetime(2012, 7, 6))
+ datetime(2012, 7, 6))
self.assertRaisesRegexp(ValueError, "is not a valid resolution",
- time_utils.floor, self.now, 12345)
+ time_utils.floor, self.now, 12345)
def test_timeago(self):
self.assertEqual(time_utils.timeago('1D', start=self.now),
View
3  cube/time_utils.py
@@ -93,7 +93,8 @@ def _interval_string_to_seconds(interval_string):
:type interval_string: str
:param interval_string: Interval string like 1M, 1W, 1M3W4h2s...
- (s => seconds, m => minutes, h => hours, D => days, W => weeks, M => months, Y => Years).
+ (s => seconds, m => minutes, h => hours, D => days,
+ W => weeks, M => months, Y => Years).
:rtype: int
:return: The conversion in seconds of interval_string.
Please sign in to comment.
Something went wrong with that request. Please try again.