flixcloud-flix_cloud-gem 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,213 @@
1
+ require 'test_helper'
2
+
3
+ class FlixCloud::NotificationTest < Test::Unit::TestCase
4
+
5
+ context "When initializing with a string containing xml" do
6
+ setup do
7
+ @notification = FlixCloud::Notification.new(
8
+ %{<?xml version="1.0" encoding="UTF-8"?>
9
+ <job>
10
+ <finished-job-at type="datetime">2009-04-10T20:13:02Z</finished-job-at>
11
+ <id type="integer">1</id>
12
+ <initialized-job-at type="datetime">2009-04-10T20:05:28Z</initialized-job-at>
13
+ <recipe-name>testerrrr</recipe-name>
14
+ <recipe-id type="integer">172</recipe-id>
15
+ <state>successful_job</state>
16
+ <error-message>error message</error-message>
17
+ <input-media-file>
18
+ <url>s3://flixcloud-test/small.mov</url>
19
+ <width>1280</width>
20
+ <height>720</height>
21
+ <size>1732204</size>
22
+ <duration>900</duration>
23
+ <cost>0</cost>
24
+ </input-media-file>
25
+ <output-media-file>
26
+ <url>s3://flixcloud-test/fsdfasdf.mov</url>
27
+ <width>320</width>
28
+ <height>176</height>
29
+ <size>44126</size>
30
+ <duration>700</duration>
31
+ <cost>123</cost>
32
+ </output-media-file>
33
+ <watermark-file>
34
+ <url>http://dl.getdropbox.com/u/378873/zencoder_test.mov</url>
35
+ <size>1234</size>
36
+ <cost>321</cost>
37
+ </watermark-file>
38
+ </job>})
39
+ end
40
+
41
+ should "assign to all the attributes" do
42
+ assert_not_nil @notification.xml
43
+ assert_not_nil @notification.id
44
+ assert_not_nil @notification.finished_job_at
45
+ assert_not_nil @notification.initialized_job_at
46
+ assert_not_nil @notification.recipe_name
47
+ assert_not_nil @notification.recipe_id
48
+ assert_not_nil @notification.state
49
+ assert_not_nil @notification.error_message
50
+ assert_not_nil @notification.input_media_file
51
+ assert_not_nil @notification.input_media_file.size
52
+ assert_not_nil @notification.input_media_file.url
53
+ assert_not_nil @notification.input_media_file.height
54
+ assert_not_nil @notification.input_media_file.width
55
+ assert_not_nil @notification.input_media_file.cost
56
+ assert_not_nil @notification.output_media_file
57
+ assert_not_nil @notification.output_media_file.size
58
+ assert_not_nil @notification.output_media_file.url
59
+ assert_not_nil @notification.output_media_file.height
60
+ assert_not_nil @notification.output_media_file.width
61
+ assert_not_nil @notification.output_media_file.cost
62
+ assert_not_nil @notification.watermark_file
63
+ assert_not_nil @notification.watermark_file.size
64
+ assert_not_nil @notification.watermark_file.url
65
+ assert_not_nil @notification.watermark_file.cost
66
+ end
67
+ end
68
+
69
+
70
+ context "When initializing with a hash" do
71
+ setup do
72
+ @notification = FlixCloud::Notification.new({"job" => {"initialized_job_at" => "something",
73
+ "input_media_file" => {"size" => "1732204",
74
+ "url" => "s3://flixcloud-test/small.mov",
75
+ "height" => "720",
76
+ "duration" => "900",
77
+ "width" => "1280",
78
+ "cost" => "321"},
79
+ "watermark_file" => {"size" => "1234",
80
+ "url" => "http://dl.getdropbox.com/u/378873/zencoder_test.mov",
81
+ "cost" => "0"},
82
+ "output_media_file" => {"size" => "44126",
83
+ "url" => "s3://flixcloud-test/fsdfasdf.mov",
84
+ "height" => "176",
85
+ "duration" => "700",
86
+ "width" => "320",
87
+ "cost" => "123"},
88
+ "id" => 1,
89
+ "recipe_id" => 172,
90
+ "error_message" => 'error message',
91
+ "finished_job_at" => 'something else',
92
+ "recipe_name"=>"testerrrr",
93
+ "state"=>"successful_job"}})
94
+ end
95
+
96
+ should "assign to all the attributes except the xml attribute" do
97
+ assert_nil @notification.xml
98
+ assert_not_nil @notification.id
99
+ assert_not_nil @notification.finished_job_at
100
+ assert_not_nil @notification.initialized_job_at
101
+ assert_not_nil @notification.recipe_name
102
+ assert_not_nil @notification.recipe_id
103
+ assert_not_nil @notification.state
104
+ assert_not_nil @notification.error_message
105
+ assert_not_nil @notification.input_media_file
106
+ assert_not_nil @notification.input_media_file.size
107
+ assert_not_nil @notification.input_media_file.url
108
+ assert_not_nil @notification.input_media_file.height
109
+ assert_not_nil @notification.input_media_file.width
110
+ assert_not_nil @notification.input_media_file.cost
111
+ assert_not_nil @notification.output_media_file
112
+ assert_not_nil @notification.output_media_file.size
113
+ assert_not_nil @notification.output_media_file.url
114
+ assert_not_nil @notification.output_media_file.height
115
+ assert_not_nil @notification.output_media_file.width
116
+ assert_not_nil @notification.output_media_file.cost
117
+ assert_not_nil @notification.watermark_file
118
+ assert_not_nil @notification.watermark_file.size
119
+ assert_not_nil @notification.watermark_file.url
120
+ assert_not_nil @notification.watermark_file.cost
121
+ end
122
+ end
123
+
124
+
125
+ context "When initializing with a hash and the parameters are not nested beneath 'job'" do
126
+ setup do
127
+ @notification = FlixCloud::Notification.new({"initialized_job_at" => "something",
128
+ "input_media_file" => {"size" => "1732204",
129
+ "url" => "s3://flixcloud-test/small.mov",
130
+ "height" => "720",
131
+ "duration" => "900",
132
+ "width" => "1280",
133
+ "cost" => "321"},
134
+ "watermark_file" => {"size" => "1234",
135
+ "url" => "http://dl.getdropbox.com/u/378873/zencoder_test.mov",
136
+ "cost" => "321"},
137
+ "output_media_file" => {"size" => "44126",
138
+ "url" => "s3://flixcloud-test/fsdfasdf.mov",
139
+ "height" => "176",
140
+ "duration" => "700",
141
+ "width" => "320",
142
+ "cost" => "321"},
143
+ "id" => 1,
144
+ "recipe_id" => 172,
145
+ "error_message" => 'error message',
146
+ "finished_job_at" => 'something else',
147
+ "recipe_name"=>"testerrrr",
148
+ "state"=>"successful_job"})
149
+ end
150
+
151
+ should "assign to all the attributes except the xml attribute" do
152
+ assert_nil @notification.xml
153
+ assert_not_nil @notification.id
154
+ assert_not_nil @notification.finished_job_at
155
+ assert_not_nil @notification.initialized_job_at
156
+ assert_not_nil @notification.recipe_name
157
+ assert_not_nil @notification.recipe_id
158
+ assert_not_nil @notification.state
159
+ assert_not_nil @notification.error_message
160
+ assert_not_nil @notification.input_media_file
161
+ assert_not_nil @notification.input_media_file.size
162
+ assert_not_nil @notification.input_media_file.url
163
+ assert_not_nil @notification.input_media_file.height
164
+ assert_not_nil @notification.input_media_file.width
165
+ assert_not_nil @notification.input_media_file.cost
166
+ assert_not_nil @notification.output_media_file
167
+ assert_not_nil @notification.output_media_file.size
168
+ assert_not_nil @notification.output_media_file.url
169
+ assert_not_nil @notification.output_media_file.height
170
+ assert_not_nil @notification.output_media_file.width
171
+ assert_not_nil @notification.output_media_file.cost
172
+ assert_not_nil @notification.watermark_file
173
+ assert_not_nil @notification.watermark_file.size
174
+ assert_not_nil @notification.watermark_file.url
175
+ assert_not_nil @notification.watermark_file.cost
176
+ end
177
+ end
178
+
179
+
180
+ context "With a notification where the state is 'successful_job'" do
181
+ setup do
182
+ @notification = FlixCloud::Notification.new("state" => "successful_job")
183
+ end
184
+
185
+ should "be successful" do
186
+ assert @notification.successful?
187
+ end
188
+ end
189
+
190
+
191
+ context "With a notification where the state is 'failed_job'" do
192
+ setup do
193
+ @notification = FlixCloud::Notification.new("state" => "failed_job")
194
+ end
195
+
196
+ should "be failed" do
197
+ assert @notification.failed?
198
+ end
199
+ end
200
+
201
+
202
+ context "With a notification where the state is 'cancelled_job'" do
203
+ setup do
204
+ @notification = FlixCloud::Notification.new("state" => "cancelled_job")
205
+ end
206
+
207
+ should "be cancelled" do
208
+ assert @notification.cancelled?
209
+ end
210
+ end
211
+
212
+
213
+ end
@@ -0,0 +1,20 @@
1
+ require 'test_helper'
2
+
3
+ class FlixCloud::ParametersTest < Test::Unit::TestCase
4
+
5
+ context "When validating a parameters object with no attributes set" do
6
+ setup do
7
+ @parameters = FlixCloud::Parameters.new
8
+ @parameters.valid?
9
+ end
10
+
11
+ should "require user" do
12
+ assert_match /user is required/, @parameters.errors.to_s
13
+ end
14
+
15
+ should "require password" do
16
+ assert_match /password is required/, @parameters.errors.to_s
17
+ end
18
+ end
19
+
20
+ end
@@ -0,0 +1,50 @@
1
+ require 'test_helper'
2
+
3
+ class FlixCloud::BogusRecordTestClass < FlixCloud::Record
4
+ record_column :bogus_record_test_child, 'BogusRecordTestChildClass'
5
+ end
6
+
7
+ class FlixCloud::BogusRecordTestChildClass < FlixCloud::Record
8
+ attr_accessor :bogus_attribute
9
+ end
10
+
11
+ class FlixCloud::RecordTest < Test::Unit::TestCase
12
+
13
+ context "With a record object initialized with no options" do
14
+ setup do
15
+ @record = FlixCloud::Record.new
16
+ end
17
+
18
+ should "intialize errors to an empty array" do
19
+ assert_equal [], @record.errors
20
+ end
21
+ end
22
+
23
+ context "With a record object initialized with options" do
24
+ setup do
25
+ @record = FlixCloud::Record.new(:errors => 'will be set, but', :bad_attributes => 'will not be set')
26
+ end
27
+
28
+ should "set the values of attributes that have attr_writers" do
29
+ assert_equal 'will be set, but', @record.errors
30
+ end
31
+ end
32
+
33
+ context "With a bogus class has a record column and has been initialized with attributes" do
34
+ setup do
35
+ @bogus_record = FlixCloud::BogusRecordTestClass.new(:bogus_record_test_child => {:bogus_attribute => 'bogus value'})
36
+ end
37
+
38
+ should "initialize both the parent class and the child class appropriately, assigning to the child attributes" do
39
+ assert_not_nil @bogus_record
40
+ assert @bogus_record.bogus_record_test_child.is_a?(FlixCloud::BogusRecordTestChildClass)
41
+ assert_equal 'bogus value', @bogus_record.bogus_record_test_child.bogus_attribute
42
+ end
43
+
44
+ should "update the child attributes when assigning to the parent's child object attribute (confusing?)" do
45
+ @bogus_record.bogus_record_test_child = {:bogus_attribute => 'a new bogus value'}
46
+ assert_equal 'a new bogus value', @bogus_record.bogus_record_test_child.bogus_attribute
47
+ end
48
+ end
49
+
50
+ end
@@ -0,0 +1,56 @@
1
+ require 'test_helper'
2
+
3
+ class FlixCloud::ResponseTest < Test::Unit::TestCase
4
+
5
+ context "A response initialized with a rest client response" do
6
+ setup do
7
+ @rest_client_response = stub_rest_client_response(201, '<?xml version="1.0" encoding="UTF-8"?><something>wonderful</something>')
8
+ @response = FlixCloud::Response.new(@rest_client_response)
9
+ end
10
+
11
+ should "store code in the code attribute" do
12
+ assert_equal @rest_client_response.code, @response.code
13
+ end
14
+
15
+ should "store the body of the message in the body attribute" do
16
+ assert_equal @rest_client_response.to_s, @response.body
17
+ end
18
+
19
+ should "store body converted to a hash in the body_as_hash attribute" do
20
+ assert_equal Crack::XML.parse(@rest_client_response.to_s), @response.body_as_hash
21
+ end
22
+
23
+ should "initialize errors to an empty array" do
24
+ assert_equal [], @response.errors
25
+ end
26
+ end
27
+
28
+ context "A response initialized with a rest client response with a blank message body" do
29
+ setup do
30
+ @response = FlixCloud::Response.new(stub_rest_client_response(201, ''))
31
+ end
32
+
33
+ should "be successful" do
34
+ assert @response.success?
35
+ end
36
+
37
+ should "have a blank array for the errors attribute" do
38
+ assert_equal [], @response.errors
39
+ end
40
+ end
41
+
42
+ context "A response initialized with a rest client response with a message body of errors" do
43
+ setup do
44
+ @response = FlixCloud::Response.new(stub_rest_client_response(200, '<?xml version="1.0" encoding="UTF-8"?><errors><error>There was an error doing something</error></errors>'))
45
+ end
46
+
47
+ should "not be successful" do
48
+ assert !@response.success?
49
+ end
50
+
51
+ should "store the errors in the errors attribute" do
52
+ assert_equal ['There was an error doing something'], @response.errors
53
+ end
54
+ end
55
+
56
+ end
@@ -0,0 +1,15 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+ require 'mocha'
5
+ require 'fakeweb'
6
+
7
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
8
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
9
+ require 'flix_cloud'
10
+
11
+ class Test::Unit::TestCase
12
+ def stub_rest_client_response(code, body)
13
+ stub(:code => code, :to_s => body)
14
+ end
15
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flixcloud-flix_cloud-gem
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.3
5
+ platform: ruby
6
+ authors:
7
+ - Nathan Sutton
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-04-17 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: builder
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.1.2
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: crack
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.1.1
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: sevenwire-http_client
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 0.1.0
44
+ version:
45
+ description:
46
+ email: nate@sevenwire.com
47
+ executables: []
48
+
49
+ extensions: []
50
+
51
+ extra_rdoc_files:
52
+ - LICENSE
53
+ - README.markdown
54
+ files:
55
+ - LICENSE
56
+ - README.markdown
57
+ - Rakefile
58
+ - VERSION.yml
59
+ - lib/flix_cloud.rb
60
+ - lib/flix_cloud/exceptions.rb
61
+ - lib/flix_cloud/extensions/hash.rb
62
+ - lib/flix_cloud/file.rb
63
+ - lib/flix_cloud/file_locations.rb
64
+ - lib/flix_cloud/job.rb
65
+ - lib/flix_cloud/notification.rb
66
+ - lib/flix_cloud/parameters.rb
67
+ - lib/flix_cloud/record.rb
68
+ - lib/flix_cloud/response.rb
69
+ - test/flix_cloud/file_locations_test.rb
70
+ - test/flix_cloud/file_test.rb
71
+ - test/flix_cloud/job_test.rb
72
+ - test/flix_cloud/notification_test.rb
73
+ - test/flix_cloud/parameters_test.rb
74
+ - test/flix_cloud/record_test.rb
75
+ - test/flix_cloud/response_test.rb
76
+ - test/test_helper.rb
77
+ has_rdoc: true
78
+ homepage: http://github.com/zencoder/flix_cloud-gem
79
+ post_install_message:
80
+ rdoc_options:
81
+ - --charset=UTF-8
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: "0"
89
+ version:
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: "0"
95
+ version:
96
+ requirements: []
97
+
98
+ rubyforge_project:
99
+ rubygems_version: 1.2.0
100
+ signing_key:
101
+ specification_version: 2
102
+ summary: Gem for integrating with http://flixcloud.com
103
+ test_files:
104
+ - test/flix_cloud/file_locations_test.rb
105
+ - test/flix_cloud/file_test.rb
106
+ - test/flix_cloud/job_test.rb
107
+ - test/flix_cloud/notification_test.rb
108
+ - test/flix_cloud/parameters_test.rb
109
+ - test/flix_cloud/record_test.rb
110
+ - test/flix_cloud/response_test.rb
111
+ - test/test_helper.rb