studio_api 3.1.0 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,50 +1,58 @@
1
- require 'rubygems'
2
- require 'active_support'
3
- require 'active_resource/http_mock'
4
- require 'mocha'
5
- require 'test/unit'
6
- $:.unshift File.join( File.dirname(__FILE__), '..', 'lib')
7
- require 'studio_api/running_build'
8
- require 'studio_api/connection'
1
+ require 'test_helper'
9
2
 
10
3
  class RunningBuildTest < Test::Unit::TestCase
11
- BUILD_ID = 529783
12
- APPLIANCE_ID = 269186
13
-
14
- def respond_load name
15
- IO.read(File.join(File.dirname(__FILE__), "responses", name))
16
- end
17
4
 
18
5
  def setup
19
- @connection = StudioApi::Connection.new("test", "test", "http://localhost")
20
- StudioApi::RunningBuild.studio_connection = @connection
6
+ @build_id = 529783
7
+ @appliance_id = 269186
21
8
 
22
- running_builds_out = respond_load "running_builds.xml"
23
- running_build_out = respond_load "running_build.xml"
9
+ FakeWeb.clean_registry
10
+ FakeWeb.allow_net_connect = false
11
+ @connection = StudioApi::Connection.new(@@username, @@password,"http://localhost/api/")
12
+ StudioApi::RunningBuild.studio_connection = @connection
13
+ end
24
14
 
25
- ActiveResource::HttpMock.respond_to do |mock|
26
- mock.get "/running_builds?appliance_id=#{APPLIANCE_ID}", {"Authorization"=>"Basic dGVzdDp0ZXN0"}, running_builds_out, 200
27
- mock.get "/running_builds/#{BUILD_ID}", {"Authorization"=>"Basic dGVzdDp0ZXN0"}, running_build_out, 200
28
- mock.delete "/running_builds/#{BUILD_ID}", {"Authorization"=>"Basic dGVzdDp0ZXN0"}, running_build_out, 200
29
- mock.post "/running_builds?appliance_id=#{APPLIANCE_ID}&force=true", {"Authorization"=>"Basic dGVzdDp0ZXN0"}, running_build_out, 200
30
- end
15
+ def teardown
16
+ FakeWeb.allow_net_connect = false
31
17
  end
32
18
 
33
19
  def test_find
34
- res = StudioApi::RunningBuild.find :all, :params => {:appliance_id => APPLIANCE_ID}
20
+ register_fake_response_from_file :get, "/api/running_builds?appliance_id=#{@appliance_id}",
21
+ 'running_builds.xml'
22
+ res = StudioApi::RunningBuild.find :all, :params => {:appliance_id => @appliance_id}
35
23
  assert_equal 3, res.size
36
- res = StudioApi::RunningBuild.find BUILD_ID
37
- assert_equal BUILD_ID, res.id.to_i
24
+
25
+ register_fake_response_from_file :get, "/api/running_builds/#{@build_id}",
26
+ 'running_build.xml'
27
+ res = StudioApi::RunningBuild.find @build_id
28
+ assert_equal @build_id, res.id.to_i
38
29
  end
39
30
 
40
31
  def test_cancel
41
- running_build = StudioApi::RunningBuild.find BUILD_ID
32
+ register_fake_response_from_file :get, "/api/running_builds/#{@build_id}",
33
+ 'running_build.xml'
34
+ running_build = StudioApi::RunningBuild.find @build_id
35
+
36
+ register_fake_response_from_file :delete, "/api/running_builds/#{@build_id}",
37
+ 'running_build.xml'
42
38
  assert running_build.destroy
43
- assert StudioApi::RunningBuild.delete BUILD_ID
39
+ assert StudioApi::RunningBuild.delete @build_id
44
40
  assert running_build.cancel #test alias
45
41
  end
46
42
 
47
43
  def test_run_new
48
- assert StudioApi::RunningBuild.new(:appliance_id => APPLIANCE_ID, :force => true).save
44
+ register_fake_response_from_file :post, "/api/running_builds?appliance_id=#{@appliance_id}&force=true",
45
+ 'running_build.xml'
46
+ assert StudioApi::RunningBuild.new(:appliance_id => @appliance_id, :force => true).save
47
+ end
48
+
49
+ def test_find_image_already_exists_error
50
+ register_fake_response_from_file :post, "/api/running_builds?appliance_id=#{@appliance_id}",
51
+ 'running_build_image_already_exists.xml',
52
+ ["400", "Bad Request"]
53
+
54
+ assert_raises StudioApi::ImageAlreadyExists do
55
+ StudioApi::RunningBuild.new(:appliance_id => @appliance_id).save
56
+ end
49
57
  end
50
58
  end
@@ -1,32 +1,21 @@
1
- require 'rubygems'
2
- require 'active_support'
3
- require 'active_resource/http_mock'
4
- require 'mocha'
5
- require 'test/unit'
6
- require 'tempfile'
7
- $:.unshift File.join( File.dirname(__FILE__), '..', 'lib')
8
- require 'studio_api/template_set'
9
- require 'studio_api/connection'
10
- require 'studio_api/generic_request'
1
+ require 'test_helper'
11
2
 
12
3
  class TemplateSetTest < Test::Unit::TestCase
13
4
 
14
- def respond_load name
15
- IO.read(File.join(File.dirname(__FILE__), "responses", name))
16
- end
17
-
18
5
  def setup
19
- @connection = StudioApi::Connection.new("test", "test", "http://localhost")
6
+ FakeWeb.clean_registry
7
+ FakeWeb.allow_net_connect = false
8
+ @connection = StudioApi::Connection.new(@@username, @@password,"http://localhost/api/")
20
9
  StudioApi::TemplateSet.studio_connection = @connection
10
+ end
21
11
 
22
- template_sets_out = respond_load "template_sets.xml"
23
-
24
- ActiveResource::HttpMock.respond_to do |mock|
25
- mock.get "/template_sets", {"Authorization"=>"Basic dGVzdDp0ZXN0"}, template_sets_out, 200
26
- end
12
+ def teardown
13
+ FakeWeb.allow_net_connect = false
27
14
  end
28
15
 
29
16
  def test_find
17
+ register_fake_response_from_file :get, "/api/template_sets",
18
+ 'template_sets.xml'
30
19
  res = StudioApi::TemplateSet.find :all
31
20
  assert_equal 6, res.size
32
21
  assert_equal 42, res[0].template.size
@@ -0,0 +1,25 @@
1
+ require File.expand_path('../../lib/studio_api',__FILE__)
2
+
3
+ require 'fakeweb'
4
+ require 'mocha'
5
+ require 'test/unit'
6
+
7
+ class Test::Unit::TestCase
8
+ @@username = "foo"
9
+ @@password = "api_password"
10
+ private
11
+
12
+ def register_fake_response request_type, request, response,
13
+ status = ["200", "OK"]
14
+ url = "http://#{@@username}:#{@@password}@localhost#{request}"
15
+ FakeWeb.register_uri(request_type, url, :body => response, :status => status)
16
+ end
17
+
18
+ def register_fake_response_from_file request_type, request, response_file_name,
19
+ status = ["200", "OK"]
20
+ response = IO.read(File.join(File.dirname(__FILE__),"responses",
21
+ response_file_name))
22
+ register_fake_response request_type, request, response, status
23
+ end
24
+ end
25
+
@@ -1,38 +1,25 @@
1
- require 'rubygems'
2
- require 'active_support'
3
- require 'active_resource/http_mock'
4
- require 'mocha'
5
- require 'test/unit'
6
- $:.unshift File.join( File.dirname(__FILE__), '..', 'lib')
7
- require 'studio_api/testdrive'
8
- require 'studio_api/connection'
1
+ require 'test_helper'
9
2
 
10
3
  class TestdriveTest < Test::Unit::TestCase
11
- BUILD_ID = 12345
12
-
13
- def respond_load name
14
- IO.read(File.join(File.dirname(__FILE__), "responses", name))
15
- end
16
-
17
4
  def setup
18
- @connection = StudioApi::Connection.new("test", "test", "http://localhost")
19
- StudioApi::Testdrive.studio_connection = @connection
20
-
21
- testdrives_out = respond_load "testdrives.xml"
22
- testdrive_out = respond_load "testdrive.xml"
5
+ @build_id = 12345
23
6
 
24
- ActiveResource::HttpMock.respond_to do |mock|
25
- mock.get "/testdrives", {"Authorization"=>"Basic dGVzdDp0ZXN0"}, testdrives_out, 200
26
- mock.post "/testdrives?build_id=#{BUILD_ID}", {"Authorization"=>"Basic dGVzdDp0ZXN0"}, testdrive_out, 200
27
- end
7
+ FakeWeb.clean_registry
8
+ FakeWeb.allow_net_connect = false
9
+ @connection = StudioApi::Connection.new(@@username, @@password,"http://localhost/api/")
10
+ StudioApi::Testdrive.studio_connection = @connection
28
11
  end
29
12
 
30
13
  def test_find
31
- res = StudioApi::Testdrive.all
14
+ register_fake_response_from_file :get, "/api/testdrives",
15
+ 'testdrives.xml'
16
+ res = StudioApi::Testdrive.find :all
32
17
  assert_equal 1, res.size
33
18
  end
34
19
 
35
20
  def test_new
36
- assert StudioApi::Testdrive.new(:build_id => BUILD_ID).save
21
+ register_fake_response_from_file :post, "/api/testdrives?build_id=#{@build_id}",
22
+ 'testdrive.xml'
23
+ assert StudioApi::Testdrive.new(:build_id => @build_id).save
37
24
  end
38
25
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: studio_api
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 1
9
- - 0
10
- version: 3.1.0
9
+ - 1
10
+ version: 3.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Josef Reidinger
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-02 00:00:00 +02:00
18
+ date: 2011-05-06 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -50,21 +50,37 @@ dependencies:
50
50
  version: 1.0.0
51
51
  type: :runtime
52
52
  version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: yard
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 3
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ type: :development
66
+ version_requirements: *id003
53
67
  description: |-
54
68
  Studio Api makes it easier to use SuSE Studio (http://susestudio.com) via API.
55
- Instead of adapting each ActiveResource to its behavior and
56
- manually adding multipart file upload it wrapp in in Active
57
- Resource like interface. It is possible to define credentials
58
- for whole api, or use it per partes, so it allow using it for
59
- different studio users together.
69
+ Instead of adapting each ActiveResource to its behavior and
70
+ manually adding multipart file upload it wrapp in in Active
71
+ Resource like interface. It is possible to define credentials
72
+ for whole api, or use it per partes, so it allow using it for
73
+ different studio users together.
60
74
  email: jreidinger@suse.cz
61
75
  executables: []
62
76
 
63
77
  extensions: []
64
78
 
65
- extra_rdoc_files: []
66
-
79
+ extra_rdoc_files:
80
+ - README
67
81
  files:
82
+ - .gitignore
83
+ - Gemfile
68
84
  - README
69
85
  - Rakefile
70
86
  - VERSION
@@ -85,6 +101,8 @@ files:
85
101
  - lib/studio_api/template_set.rb
86
102
  - lib/studio_api/testdrive.rb
87
103
  - lib/studio_api/util.rb
104
+ - rubygem-studio_api.changes
105
+ - rubygem-studio_api.spec.template
88
106
  - test/appliance_test.rb
89
107
  - test/build_test.rb
90
108
  - test/connection_test.rb
@@ -93,10 +111,7 @@ files:
93
111
  - test/generic_request_test.rb
94
112
  - test/repository_test.rb
95
113
  - test/resource_test.rb
96
- - test/rpm_test.rb
97
- - test/running_build_test.rb
98
- - test/template_set_test.rb
99
- - test/testdrive_test.rb
114
+ - test/responses/api_version.xml
100
115
  - test/responses/appliance.xml
101
116
  - test/responses/appliances.xml
102
117
  - test/responses/build.xml
@@ -114,8 +129,10 @@ files:
114
129
  - test/responses/rpm.xml
115
130
  - test/responses/rpms.xml
116
131
  - test/responses/running_build.xml
132
+ - test/responses/running_build_image_already_exists.xml
117
133
  - test/responses/running_builds.xml
118
134
  - test/responses/software.xml
135
+ - test/responses/software_fake_response.xml
119
136
  - test/responses/software_installed.xml
120
137
  - test/responses/software_search.xml
121
138
  - test/responses/status-broken.xml
@@ -127,6 +144,11 @@ files:
127
144
  - test/responses/users_1.xml
128
145
  - test/responses/users_2.xml
129
146
  - test/responses/versions.xml
147
+ - test/rpm_test.rb
148
+ - test/running_build_test.rb
149
+ - test/template_set_test.rb
150
+ - test/test_helper.rb
151
+ - test/testdrive_test.rb
130
152
  has_rdoc: true
131
153
  homepage: http://github.com/jreidinger/studio_api
132
154
  licenses:
@@ -136,7 +158,7 @@ post_install_message:
136
158
  rdoc_options:
137
159
  - --line-numbers
138
160
  - --main
139
- - README.rdoc
161
+ - README
140
162
  require_paths:
141
163
  - lib
142
164
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -153,14 +175,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
175
  requirements:
154
176
  - - ">="
155
177
  - !ruby/object:Gem::Version
156
- hash: 3
178
+ hash: 23
157
179
  segments:
158
- - 0
159
- version: "0"
180
+ - 1
181
+ - 3
182
+ - 6
183
+ version: 1.3.6
160
184
  requirements: []
161
185
 
162
- rubyforge_project:
163
- rubygems_version: 1.5.1
186
+ rubyforge_project: studio_api
187
+ rubygems_version: 1.6.2
164
188
  signing_key:
165
189
  specification_version: 3
166
190
  summary: Intuitive ruby bindings to Studio Api Interface.
@@ -173,6 +197,7 @@ test_files:
173
197
  - test/generic_request_test.rb
174
198
  - test/repository_test.rb
175
199
  - test/resource_test.rb
200
+ - test/responses/api_version.xml
176
201
  - test/responses/appliance.xml
177
202
  - test/responses/appliances.xml
178
203
  - test/responses/build.xml
@@ -190,8 +215,10 @@ test_files:
190
215
  - test/responses/rpm.xml
191
216
  - test/responses/rpms.xml
192
217
  - test/responses/running_build.xml
218
+ - test/responses/running_build_image_already_exists.xml
193
219
  - test/responses/running_builds.xml
194
220
  - test/responses/software.xml
221
+ - test/responses/software_fake_response.xml
195
222
  - test/responses/software_installed.xml
196
223
  - test/responses/software_search.xml
197
224
  - test/responses/status-broken.xml
@@ -206,4 +233,5 @@ test_files:
206
233
  - test/rpm_test.rb
207
234
  - test/running_build_test.rb
208
235
  - test/template_set_test.rb
236
+ - test/test_helper.rb
209
237
  - test/testdrive_test.rb