44from test_util import TEST_API_KEY , load_response
55from zencoder import Zencoder
66
7+ import datetime
8+
79class TestReports (unittest .TestCase ):
810 def setUp (self ):
911 self .zen = Zencoder (api_key = TEST_API_KEY )
@@ -33,7 +35,7 @@ def test_reports_live(self, get):
3335 def test_reports_all (self , get ):
3436 get .return_value = load_response (200 , 'fixtures/report_all.json' )
3537
36- resp = self .zen .report .live ()
38+ resp = self .zen .report .all ()
3739
3840 self .assertEquals (resp .code , 200 )
3941
@@ -43,6 +45,26 @@ def test_reports_all(self, get):
4345 self .assertEquals (resp .body ['total' ]['vod' ]['billable_minutes' ], 8 )
4446 self .assertEquals (resp .body ['statistics' ]['live' ]['length' ], 2 )
4547
48+ @patch ("requests.Session.get" )
49+ def test_reports_all_date_filter (self , get ):
50+ get .return_value = load_response (200 , 'fixtures/report_all_date.json' )
51+
52+ start = datetime .date (2013 , 5 , 13 )
53+ end = datetime .date (2013 , 5 , 13 )
54+ resp = self .zen .report .all (start_date = start , end_date = end )
55+
56+ self .assertEquals (resp .code , 200 )
57+
58+ self .assertEquals (resp .body ['statistics' ]['vod' ][0 ]['encoded_minutes' ], 5 )
59+ self .assertEquals (resp .body ['statistics' ]['vod' ][0 ]['billable_minutes' ], 0 )
60+ self .assertEquals (resp .body ['statistics' ]['live' ][0 ]['stream_hours' ], 1 )
61+ self .assertEquals (resp .body ['statistics' ]['live' ][0 ]['total_hours' ], 2 )
62+
63+ self .assertEquals (resp .body ['total' ]['vod' ]['encoded_minutes' ], 5 )
64+ self .assertEquals (resp .body ['total' ]['vod' ]['billable_minutes' ], 0 )
65+ self .assertEquals (resp .body ['total' ]['live' ]['stream_hours' ], 1 )
66+ self .assertEquals (resp .body ['total' ]['live' ]['total_hours' ], 2 )
67+
4668if __name__ == "__main__" :
4769 unittest .main ()
4870
0 commit comments