4
4
from test_util import TEST_API_KEY , load_response
5
5
from zencoder import Zencoder
6
6
7
+ import datetime
8
+
7
9
class TestReports (unittest .TestCase ):
8
10
def setUp (self ):
9
11
self .zen = Zencoder (api_key = TEST_API_KEY )
@@ -33,7 +35,7 @@ def test_reports_live(self, get):
33
35
def test_reports_all (self , get ):
34
36
get .return_value = load_response (200 , 'fixtures/report_all.json' )
35
37
36
- resp = self .zen .report .live ()
38
+ resp = self .zen .report .all ()
37
39
38
40
self .assertEquals (resp .code , 200 )
39
41
@@ -43,6 +45,26 @@ def test_reports_all(self, get):
43
45
self .assertEquals (resp .body ['total' ]['vod' ]['billable_minutes' ], 8 )
44
46
self .assertEquals (resp .body ['statistics' ]['live' ]['length' ], 2 )
45
47
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
+
46
68
if __name__ == "__main__" :
47
69
unittest .main ()
48
70
0 commit comments