Permalink
Browse files

Slightly simplify asset is_active and add back doc test.

  • Loading branch information...
1 parent 8730486 commit 1215fdd7c31a54f3edadc4499560480f6bca0189 @aljungberg aljungberg committed Mar 12, 2013
Showing with 14 additions and 5 deletions.
  1. +1 −2 README.md
  2. +13 −3 assets_helper.py
View
@@ -4,5 +4,4 @@ To learn more about Screenly, please visit the official website at [ScreenlyApp.
### Running the Unit Tests
- nosetests
-
+ nosetests --with-doctest
View
@@ -13,12 +13,22 @@
def is_active(asset, at_time=None):
"""Accepts an asset dictionary and determines if it
is active at the given time. If no time is specified, 'now' is used.
+
+ >>> asset = {'asset_id': u'4c8dbce552edb5812d3a866cfe5f159d', 'mimetype': u'web', 'name': u'WireLoad', 'end_date': datetime.datetime(2013, 1, 19, 23, 59), 'uri': u'http://www.wireload.net', 'duration': u'5', 'is_enabled': True, 'nocache': 0, 'play_order': 1, 'start_date': datetime.datetime(2013, 1, 16, 0, 0)};
+ >>> is_active(asset, datetime.datetime(2013, 1, 16, 12, 00))
+ True
+ >>> is_active(asset, datetime.datetime(2014, 1, 1))
+ False
+
+ >>> asset['is_enabled'] = False
+ >>> is_active(asset, datetime.datetime(2013, 1, 16, 12, 00))
+ False
+
"""
- if asset['start_date'] and asset['end_date']:
+ if asset['is_enabled'] and asset['start_date'] and asset['end_date']:
at = at_time or get_time()
- active = asset['start_date'] < at and asset['end_date'] > at
- return active and asset['is_enabled']
+ return asset['start_date'] < at and asset['end_date'] > at
return False

0 comments on commit 1215fdd

Please sign in to comment.