@@ -26,4 +26,76 @@ class Zencoder::ReportTest < Test::Unit::TestCase
26
26
end
27
27
end
28
28
29
+ context ".all" do
30
+ setup do
31
+ @api_key = "abcd123"
32
+ @url = "#{ Zencoder . base_url } /reports/all"
33
+ end
34
+
35
+ should "GET the correct url and return a response" do
36
+ Zencoder ::HTTP . stubs ( :get ) . with ( @url , { :params => { :from => "2011-01-01" ,
37
+ :to => "2011-06-01" ,
38
+ :grouping => "foo" } ,
39
+ :headers => { "Zencoder-Api-Key" => @api_key } } ) . returns ( Zencoder ::Response . new )
40
+ assert_equal Zencoder ::Response , Zencoder ::Report . all ( :api_key => @api_key , :from => "2011-01-01" ,
41
+ :to => "2011-06-01" ,
42
+ :grouping => "foo" ) . class
43
+ end
44
+
45
+ should "merge params well" do
46
+ Zencoder ::HTTP . stubs ( :get ) . with ( @url , { :params => { :from => "2011-01-01" ,
47
+ :to => "2011-06-01" } ,
48
+ :headers => { "Zencoder-Api-Key" => @api_key } } ) . returns ( Zencoder ::Response . new )
49
+ assert_equal Zencoder ::Response , Zencoder ::Report . all ( :api_key => @api_key , :from => "2011-01-01" , :to => "2011-06-01" ) . class
50
+ end
51
+ end
52
+
53
+ context ".vod" do
54
+ setup do
55
+ @api_key = "abcd123"
56
+ @url = "#{ Zencoder . base_url } /reports/vod"
57
+ end
58
+
59
+ should "GET the correct url and return a response" do
60
+ Zencoder ::HTTP . stubs ( :get ) . with ( @url , { :params => { :from => "2011-01-01" ,
61
+ :to => "2011-06-01" ,
62
+ :grouping => "foo" } ,
63
+ :headers => { "Zencoder-Api-Key" => @api_key } } ) . returns ( Zencoder ::Response . new )
64
+ assert_equal Zencoder ::Response , Zencoder ::Report . vod ( :api_key => @api_key , :from => "2011-01-01" ,
65
+ :to => "2011-06-01" ,
66
+ :grouping => "foo" ) . class
67
+ end
68
+
69
+ should "merge params well" do
70
+ Zencoder ::HTTP . stubs ( :get ) . with ( @url , { :params => { :from => "2011-01-01" ,
71
+ :to => "2011-06-01" } ,
72
+ :headers => { "Zencoder-Api-Key" => @api_key } } ) . returns ( Zencoder ::Response . new )
73
+ assert_equal Zencoder ::Response , Zencoder ::Report . vod ( :api_key => @api_key , :from => "2011-01-01" , :to => "2011-06-01" ) . class
74
+ end
75
+ end
76
+
77
+ context ".live" do
78
+ setup do
79
+ @api_key = "abcd123"
80
+ @url = "#{ Zencoder . base_url } /reports/live"
81
+ end
82
+
83
+ should "GET the correct url and return a response" do
84
+ Zencoder ::HTTP . stubs ( :get ) . with ( @url , { :params => { :from => "2011-01-01" ,
85
+ :to => "2011-06-01" ,
86
+ :grouping => "foo" } ,
87
+ :headers => { "Zencoder-Api-Key" => @api_key } } ) . returns ( Zencoder ::Response . new )
88
+ assert_equal Zencoder ::Response , Zencoder ::Report . live ( :api_key => @api_key , :from => "2011-01-01" ,
89
+ :to => "2011-06-01" ,
90
+ :grouping => "foo" ) . class
91
+ end
92
+
93
+ should "merge params well" do
94
+ Zencoder ::HTTP . stubs ( :get ) . with ( @url , { :params => { :from => "2011-01-01" ,
95
+ :to => "2011-06-01" } ,
96
+ :headers => { "Zencoder-Api-Key" => @api_key } } ) . returns ( Zencoder ::Response . new )
97
+ assert_equal Zencoder ::Response , Zencoder ::Report . live ( :api_key => @api_key , :from => "2011-01-01" , :to => "2011-06-01" ) . class
98
+ end
99
+ end
100
+
29
101
end
0 commit comments