Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d8856a6

Browse filesBrowse files
author
Alex Schworer
committed
Add tests for start_date and end_date Report filtering
1 parent 187cb2e commit d8856a6
Copy full SHA for d8856a6

File tree

2 files changed

+61
-1
lines changed
Filter options

2 files changed

+61
-1
lines changed

‎test/fixtures/report_all_date.json

Copy file name to clipboard
+38Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"statistics": {
3+
"vod": [
4+
{
5+
"encoded_minutes": 5,
6+
"billable_minutes": 0,
7+
"grouping": null,
8+
"collected_on": "2013-05-13"
9+
}
10+
],
11+
"live": [
12+
{
13+
"total_billable_hours": 2,
14+
"stream_hours": 1,
15+
"billable_stream_hours": 0,
16+
"encoded_hours": 2,
17+
"grouping": null,
18+
"collected_on": "2013-05-13",
19+
"billable_encoded_hours": 0,
20+
"total_hours": 2
21+
}
22+
]
23+
},
24+
"total": {
25+
"vod": {
26+
"encoded_minutes": 5,
27+
"billable_minutes": 0
28+
},
29+
"live": {
30+
"total_billable_hours": 2,
31+
"stream_hours": 1,
32+
"billable_stream_hours": 0,
33+
"encoded_hours": 2,
34+
"billable_encoded_hours": 0,
35+
"total_hours": 2
36+
}
37+
}
38+
}

‎test/test_reports.py

Copy file name to clipboardExpand all lines: test/test_reports.py
+23-1Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
from test_util import TEST_API_KEY, load_response
55
from zencoder import Zencoder
66

7+
import datetime
8+
79
class 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+
4668
if __name__ == "__main__":
4769
unittest.main()
4870

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.