[PATCH conductor 5/5] Fixed tests after removing warehouse models
Tomas Hrcka
thrcka at redhat.com
Wed Dec 14 15:28:14 UTC 2011
On 12/14/2011 03:09 PM, jprovazn at redhat.com wrote:
> From: Jan Provaznik<jprovazn at redhat.com>
>
> ---
> src/spec/controllers/api/builds_controller_spec.rb | 2 +-
> src/spec/controllers/api/images_controller_spec.rb | 2 +-
> src/spec/models/deployment_spec.rb | 2 +-
> src/spec/models/image_build_spec.rb | 55 ----------
> src/spec/models/image_spec.rb | 47 ---------
> src/spec/models/instance_spec.rb | 8 +-
> src/spec/models/provider_image_spec.rb | 56 ----------
> src/spec/models/target_image_spec.rb | 49 ---------
> src/spec/vcr/cassettes/iwhd_connection.yml | 106 ++++++++++++++++++++
> src/spec/vcr_setup.rb | 2 +-
> 10 files changed, 114 insertions(+), 215 deletions(-)
> delete mode 100644 src/spec/models/image_build_spec.rb
> delete mode 100644 src/spec/models/image_spec.rb
> delete mode 100644 src/spec/models/provider_image_spec.rb
> delete mode 100644 src/spec/models/target_image_spec.rb
>
> diff --git a/src/spec/controllers/api/builds_controller_spec.rb b/src/spec/controllers/api/builds_controller_spec.rb
> index 31115f2..7dced00 100644
> --- a/src/spec/controllers/api/builds_controller_spec.rb
> +++ b/src/spec/controllers/api/builds_controller_spec.rb
> @@ -36,7 +36,7 @@ describe Api::BuildsController do
> :id => '10',
> :image => @image,
> :target_images => [@target_image],
> - :provider_images => [mock(ProviderImage, :target_identifier => "ami-1234567", :provider => "provider")] * 2)
> + :provider_images => [mock(Aeolus::Image::Warehouse::ProviderImage, :target_identifier => "ami-1234567", :provider => "provider")] * 2)
> end
>
> context "when authenticated as admin" do
> diff --git a/src/spec/controllers/api/images_controller_spec.rb b/src/spec/controllers/api/images_controller_spec.rb
> index f99dc91..b880352 100644
> --- a/src/spec/controllers/api/images_controller_spec.rb
> +++ b/src/spec/controllers/api/images_controller_spec.rb
> @@ -35,7 +35,7 @@ describe Api::ImagesController do
> :description => 'test image',
> :image_builds => [@build],
> :build => @build,
> - :provider_images => [mock(ProviderImage, :target_identifier => "ami-1234567", :provider => "provider")] * 2
> + :provider_images => [mock(Aeolus::Image::Warehouse::ProviderImage, :target_identifier => "ami-1234567", :provider => "provider")] * 2
> )
> Aeolus::Image::Warehouse::ImageBuild.stub(:where).and_return([@build])
> end
> diff --git a/src/spec/models/deployment_spec.rb b/src/spec/models/deployment_spec.rb
> index 54a4f2a..1a60dd7 100644
> --- a/src/spec/models/deployment_spec.rb
> +++ b/src/spec/models/deployment_spec.rb
> @@ -154,7 +154,7 @@ describe Deployment do
> describe "using image from iwhd" do
> before do
> image_id = @deployment.deployable_xml.assemblies.first.image_id
> - provider_name = Image.find(image_id).latest_build.provider_images.first.provider_name
> + provider_name = Aeolus::Image::Warehouse::Image.find(image_id).latest_pushed_build.provider_images.first.provider_name
> provider = FactoryGirl.create(:mock_provider, :name => provider_name)
> @deployment.pool.pool_family.provider_accounts = [FactoryGirl.create(:mock_provider_account, :label => 'testaccount', :provider => provider)]
> admin_perms = FactoryGirl.create :admin_permission
> diff --git a/src/spec/models/image_build_spec.rb b/src/spec/models/image_build_spec.rb
> deleted file mode 100644
> index a1779e6..0000000
> --- a/src/spec/models/image_build_spec.rb
> +++ /dev/null
> @@ -1,55 +0,0 @@
> -#
> -# Copyright 2011 Red Hat, Inc.
> -#
> -# Licensed under the Apache License, Version 2.0 (the "License");
> -# you may not use this file except in compliance with the License.
> -# You may obtain a copy of the License at
> -#
> -# http://www.apache.org/licenses/LICENSE-2.0
> -#
> -# Unless required by applicable law or agreed to in writing, software
> -# distributed under the License is distributed on an "AS IS" BASIS,
> -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> -# See the License for the specific language governing permissions and
> -# limitations under the License.
> -#
> -
> -require 'spec_helper'
> -
> -describe ImageBuild do
> -
> - describe "all" do
> - it "should contain testing object" do
> - ImageBuild.all.select {|i| i.uuid == "63838705-8608-44c6-aded-7c243137172c"}.size.should == 1
> - end
> - end
> -
> - describe "find" do
> - it "should contain testing object" do
> - ImageBuild.find('63838705-8608-44c6-aded-7c243137172c').uuid.should == "63838705-8608-44c6-aded-7c243137172c"
> - end
> -
> - it "should return nil" do
> - ImageBuild.find('give_me_nil').should == nil
> - end
> - end
> -
> - describe "image" do
> - it "should return image" do
> - ImageBuild.find("63838705-8608-44c6-aded-7c243137172c").image.should ==
> - Image.find("53d2a281-448b-4872-b1b0-680edaad5922")
> - end
> - end
> -
> - describe "target and provider images" do
> - it "should return target images" do
> - ImageBuild.find("63838705-8608-44c6-aded-7c243137172c").target_images.should include \
> - TargetImage.find("1a955a06-ca92-4546-9121-6c35e162f67b")
> - end
> -
> - it "should return provider images" do
> - ImageBuild.find("63838705-8608-44c6-aded-7c243137172c").provider_images.should include \
> - ProviderImage.find("3cdd9f26-b211-454b-89ff-655b0ebbff03")
> - end
> - end
> -end
> diff --git a/src/spec/models/image_spec.rb b/src/spec/models/image_spec.rb
> deleted file mode 100644
> index 8f0bdd2..0000000
> --- a/src/spec/models/image_spec.rb
> +++ /dev/null
> @@ -1,47 +0,0 @@
> -#
> -# Copyright 2011 Red Hat, Inc.
> -#
> -# Licensed under the Apache License, Version 2.0 (the "License");
> -# you may not use this file except in compliance with the License.
> -# You may obtain a copy of the License at
> -#
> -# http://www.apache.org/licenses/LICENSE-2.0
> -#
> -# Unless required by applicable law or agreed to in writing, software
> -# distributed under the License is distributed on an "AS IS" BASIS,
> -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> -# See the License for the specific language governing permissions and
> -# limitations under the License.
> -#
> -
> -require 'spec_helper'
> -
> -describe Image do
> - describe "all" do
> - it "should contain testing object" do
> - Image.all.select {|i| i.uuid == "53d2a281-448b-4872-b1b0-680edaad5922"}.size.should == 1
> - end
> - end
> -
> - describe "find" do
> - it "should containt testing object" do
> - Image.find("53d2a281-448b-4872-b1b0-680edaad5922").uuid.should == "53d2a281-448b-4872-b1b0-680edaad5922"
> - end
> -
> - it "should return nil" do
> - Image.find('give_me_nil').should == nil
> - end
> - end
> -
> - describe "latest build" do
> - it "should return build list" do
> - Image.find("53d2a281-448b-4872-b1b0-680edaad5922").image_builds.should include \
> - ImageBuild.find("63838705-8608-44c6-aded-7c243137172c")
> - end
> -
> - it "should return latest build" do
> - Image.find("53d2a281-448b-4872-b1b0-680edaad5922").latest_build.should ==
> - ImageBuild.find("63838705-8608-44c6-aded-7c243137172c")
> - end
> - end
> -end
> diff --git a/src/spec/models/instance_spec.rb b/src/spec/models/instance_spec.rb
> index b4c0646..a1fe525 100644
> --- a/src/spec/models/instance_spec.rb
> +++ b/src/spec/models/instance_spec.rb
> @@ -167,7 +167,7 @@ describe Instance do
> it "should not return matches if account quota is exceeded" do
> # Other tests expect that @instance is built but not created, but we need it saved:
> @instance.save!
> - build = @instance.image_build || @instance.image.latest_build
> + build = @instance.image_build || @instance.image.latest_pushed_build
> provider = FactoryGirl.create(:mock_provider, :name => build.provider_images.first.provider_name)
> account = FactoryGirl.create(:mock_provider_account, :provider => provider, :label => 'testaccount')
> @pool.pool_family.provider_accounts = [account]
> @@ -205,7 +205,7 @@ describe Instance do
> end
>
> it "should return a match if all requirements are satisfied" do
> - build = @instance.image_build || @instance.image.latest_build
> + build = @instance.image_build || @instance.image.latest_pushed_build
> provider = FactoryGirl.create(:mock_provider, :name => build.provider_images.first.provider_name)
> @pool.pool_family.provider_accounts = [FactoryGirl.create(:mock_provider_account, :label => 'testaccount', :provider => provider)]
> @instance.matches.first.should_not be_empty
> @@ -273,7 +273,7 @@ describe Instance do
> end
> end
> it "should match if the account has a config server and the instance has configs" do
> - build = @instance.image_build || @instance.image.latest_build
> + build = @instance.image_build || @instance.image.latest_pushed_build
> provider = FactoryGirl.create(:mock_provider, :name => build.provider_images.first.provider_name)
> account = FactoryGirl.create(:mock_provider_account, :label => 'testaccount_config_server', :provider => provider)
> config_server = FactoryGirl.create(:mock_config_server, :provider_account => account)
> @@ -287,7 +287,7 @@ describe Instance do
> end
>
> it "should not match if the account does not have a config server and the instance has configs" do
> - build = @instance.image_build || @instance.image.latest_build
> + build = @instance.image_build || @instance.image.latest_pushed_build
> provider = FactoryGirl.create(:mock_provider, :name => build.provider_images.first.provider_name)
> account = FactoryGirl.create(:mock_provider_account, :label => 'testaccount_no_config_server', :provider => provider)
> @pool.pool_family.provider_accounts = [account]
> diff --git a/src/spec/models/provider_image_spec.rb b/src/spec/models/provider_image_spec.rb
> deleted file mode 100644
> index 75dc5a9..0000000
> --- a/src/spec/models/provider_image_spec.rb
> +++ /dev/null
> @@ -1,56 +0,0 @@
> -#
> -# Copyright 2011 Red Hat, Inc.
> -#
> -# Licensed under the Apache License, Version 2.0 (the "License");
> -# you may not use this file except in compliance with the License.
> -# You may obtain a copy of the License at
> -#
> -# http://www.apache.org/licenses/LICENSE-2.0
> -#
> -# Unless required by applicable law or agreed to in writing, software
> -# distributed under the License is distributed on an "AS IS" BASIS,
> -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> -# See the License for the specific language governing permissions and
> -# limitations under the License.
> -#
> -
> -require 'spec_helper'
> -
> -describe ProviderImage do
> - before do
> - @provider = Factory.build(:mock_provider)
> - @provider.name = "mock"
> - @provider.save
> - end
> -
> - describe "all" do
> - it "should contain testing object" do
> - ProviderImage.all.select {|i| i.uuid == "3cdd9f26-b211-454b-89ff-655b0ebbff03"}.size.should == 1
> - end
> - end
> -
> - describe "find" do
> - it "should contain testing object" do
> - ProviderImage.find('3cdd9f26-b211-454b-89ff-655b0ebbff03').uuid.should == "3cdd9f26-b211-454b-89ff-655b0ebbff03"
> - end
> -
> - it "should return nil" do
> - ProviderImage.find('give_me_nil').should == nil
> - end
> - end
> -
> - describe "target image" do
> - it "should return target image" do
> - ProviderImage.find("3cdd9f26-b211-454b-89ff-655b0ebbff03").target_image.should ==
> - TargetImage.find("1a955a06-ca92-4546-9121-6c35e162f67b")
> - end
> - end
> -
> - describe "provider" do
> - it "should return provider" do
> - ProviderImage.find("3cdd9f26-b211-454b-89ff-655b0ebbff03").provider.should ==
> - @provider
> - end
> - end
> -
> -end
> diff --git a/src/spec/models/target_image_spec.rb b/src/spec/models/target_image_spec.rb
> deleted file mode 100644
> index 9e3fddf..0000000
> --- a/src/spec/models/target_image_spec.rb
> +++ /dev/null
> @@ -1,49 +0,0 @@
> -#
> -# Copyright 2011 Red Hat, Inc.
> -#
> -# Licensed under the Apache License, Version 2.0 (the "License");
> -# you may not use this file except in compliance with the License.
> -# You may obtain a copy of the License at
> -#
> -# http://www.apache.org/licenses/LICENSE-2.0
> -#
> -# Unless required by applicable law or agreed to in writing, software
> -# distributed under the License is distributed on an "AS IS" BASIS,
> -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> -# See the License for the specific language governing permissions and
> -# limitations under the License.
> -#
> -
> -require 'spec_helper'
> -
> -describe TargetImage do
> - describe "all" do
> - it "should contain testing object" do
> - TargetImage.all.select {|i| i.uuid == "1a955a06-ca92-4546-9121-6c35e162f67b"}.size.should == 1
> - end
> - end
> -
> - describe "find" do
> - it "should contain testing object" do
> - TargetImage.find('1a955a06-ca92-4546-9121-6c35e162f67b').uuid.should == "1a955a06-ca92-4546-9121-6c35e162f67b"
> - end
> -
> - it "should return nil" do
> - TargetImage.find('give_me_nil').should == nil
> - end
> - end
> -
> - describe "image build" do
> - it "should return image build" do
> - TargetImage.find("1a955a06-ca92-4546-9121-6c35e162f67b").build.should ==
> - ImageBuild.find("63838705-8608-44c6-aded-7c243137172c")
> - end
> - end
> -
> - describe "provider images" do
> - it "should return provider images" do
> - TargetImage.find("1a955a06-ca92-4546-9121-6c35e162f67b").provider_images.should include \
> - ProviderImage.find("3cdd9f26-b211-454b-89ff-655b0ebbff03")
> - end
> - end
> -end
> diff --git a/src/spec/vcr/cassettes/iwhd_connection.yml b/src/spec/vcr/cassettes/iwhd_connection.yml
> index fea7b40..b786856 100644
> --- a/src/spec/vcr/cassettes/iwhd_connection.yml
> +++ b/src/spec/vcr/cassettes/iwhd_connection.yml
> @@ -2129,3 +2129,109 @@
> - chunked
> body:<image><name>testimg</name></image>
> http_version: "1.1"
> +- !ruby/struct:VCR::HTTPInteraction
> + request: !ruby/struct:VCR::Request
> + method: :post
> + uri: http://localhost:9090/target_images/_query
> + body: ($build == "c5fc000b-829a-4bb5-9df1-bb228da2c7ec")
> + headers:
> + accept:
> + - "*/*; q=0.5, application/xml"
> + accept-encoding:
> + - gzip, deflate
> + content-length:
> + - "50"
> + response: !ruby/struct:VCR::Response
> + status: !ruby/struct:VCR::ResponseStatus
> + code: 200
> + message: OK
> + headers:
> + date:
> + - Wed, 14 Dec 2011 11:45:15 GMT
> + transfer-encoding:
> + - chunked
> + body: |
> +<objects>
> + <object>
> + <bucket>target_images</bucket>
> + <key>ce1c6d32-5e26-4feb-9b86-83435a39b1f0</key>
> + </object>
> +</objects>
> +
> + http_version: "1.1"
> +- !ruby/struct:VCR::HTTPInteraction
> + request: !ruby/struct:VCR::Request
> + method: :post
> + uri: http://localhost:9090/provider_images/_query
> + body: ($target_image == "ce1c6d32-5e26-4feb-9b86-83435a39b1f0")
> + headers:
> + accept:
> + - "*/*; q=0.5, application/xml"
> + accept-encoding:
> + - gzip, deflate
> + content-length:
> + - "57"
> + response: !ruby/struct:VCR::Response
> + status: !ruby/struct:VCR::ResponseStatus
> + code: 200
> + message: OK
> + headers:
> + date:
> + - Wed, 14 Dec 2011 11:45:28 GMT
> + transfer-encoding:
> + - chunked
> + body: |
> +<objects>
> + <object>
> + <bucket>provider_images</bucket>
> + <key>aa57b1ab-f565-4a7a-b054-58ef5af1a053</key>
> + </object>
> +</objects>
> +
> + http_version: "1.1"
> +- !ruby/struct:VCR::HTTPInteraction
> + request: !ruby/struct:VCR::Request
> + method: :get
> + uri: http://localhost:9090/images/53d2a281-448b-4872-b1b0-680edaad5922
> + body:
> + headers:
> + accept:
> + - "*/*; q=0.5, application/xml"
> + accept-encoding:
> + - gzip, deflate
> + content-length:
> + - "0"
> + response: !ruby/struct:VCR::Response
> + status: !ruby/struct:VCR::ResponseStatus
> + code: 200
> + message: OK
> + headers:
> + date:
> + - Wed, 14 Dec 2011 12:46:15 GMT
> + transfer-encoding:
> + - chunked
> + body:<image><name>ami-01a56668</name></image>
> + http_version: "1.1"
> +- !ruby/struct:VCR::HTTPInteraction
> + request: !ruby/struct:VCR::Request
> + method: :post
> + uri: http://localhost:9090/builds/_query
> + body: ($image == "85653387-88b2-46b0-b7b2-c779d2af06c7")
> + headers:
> + accept:
> + - "*/*; q=0.5, application/xml"
> + accept-encoding:
> + - gzip, deflate
> + content-length:
> + - "50"
> + response: !ruby/struct:VCR::Response
> + status: !ruby/struct:VCR::ResponseStatus
> + code: 404
> + message: Not Found
> + headers:
> + date:
> + - Wed, 14 Dec 2011 13:53:22 GMT
> + content-length:
> + - "0"
> + body:
> + http_version: "1.1"
> diff --git a/src/spec/vcr_setup.rb b/src/spec/vcr_setup.rb
> index 3953d1f..49cbe64 100644
> --- a/src/spec/vcr_setup.rb
> +++ b/src/spec/vcr_setup.rb
> @@ -26,7 +26,7 @@ VCR.config do |c|
> end
>
> # Mock all iwhd requests
> -Warehouse::Connection.class_eval do
> +Aeolus::Image::Warehouse::Connection.class_eval do
> def do_request(path = '', opts={})
> opts[:method] ||= :get
> opts[:content] ||= ''
ACK.
More information about the aeolus-devel
mailing list