From: Michal Fojtik <[email protected]>
Signed-off-by: Michal fojtik <[email protected]> --- server/tests/drivers/rhevm/api_test.rb | 18 +++++++++++++----- server/tests/drivers/rhevm/common.rb | 11 +++++++++++ server/tests/drivers/rhevm/hardware_profiles_test.rb | 8 +++++++- server/tests/drivers/rhevm/images_test.rb | 10 +++++++++- server/tests/drivers/rhevm/instances_test.rb | 8 +++++++- server/tests/drivers/rhevm/realms_test.rb | 9 +++++++-- server/tests/drivers/rhevm/setup.rb | 14 -------------- 7 files changed, 54 insertions(+), 24 deletions(-) create mode 100644 server/tests/drivers/rhevm/common.rb delete mode 100644 server/tests/drivers/rhevm/setup.rb diff --git a/server/tests/drivers/rhevm/api_test.rb b/server/tests/drivers/rhevm/api_test.rb index eea249e..0d8d69e 100644 --- a/server/tests/drivers/rhevm/api_test.rb +++ b/server/tests/drivers/rhevm/api_test.rb @@ -7,11 +7,18 @@ module RHEVMTest include Rack::Test::Methods def app - Sinatra::Application + Rack::Builder.new { + use Rack::MatrixParams + use Rack::DriverSelect + map '/' do + use Rack::Static, :urls => ["/stylesheets", "/javascripts"], :root => "public" + run Rack::Cascade.new([Deltacloud::API]) + end + } end def test_01_it_returns_entry_points - get_auth_url '/api;driver=rhevm?force_auth=1' + get_auth_url '/api;driver=rhevm' (last_xml_response/'/api').first[:driver].should == 'rhevm' (last_xml_response/'/api/link').length.should > 0 end @@ -20,8 +27,8 @@ module RHEVMTest get_url '/api;driver=rhevm' features = (last_xml_response/'/api/link[@rel="instances"]/feature').collect { |f| f[:name] } features.include?('user_name').should == true - features.include?('hardware_profiles').should == true - features.length.should == 3 + features.include?('user_data').should == true + features.length.should == 2 end def test_03_it_has_rhevm_collections @@ -32,7 +39,8 @@ module RHEVMTest collections.include?('images').should == true collections.include?('realms').should == true collections.include?('hardware_profiles').should == true - collections.length.should == 8 + collections.include?('storage_volumes').should == true + collections.length.should == 7 end end diff --git a/server/tests/drivers/rhevm/common.rb b/server/tests/drivers/rhevm/common.rb new file mode 100644 index 0000000..1ab0f99 --- /dev/null +++ b/server/tests/drivers/rhevm/common.rb @@ -0,0 +1,11 @@ +ENV['API_USER'] = '[email protected]' +ENV['API_PASSWORD'] = '123456' +ENV['API_PROVIDER'] = 'https://rhev30-dc.lab.eng.brq.redhat.com:8443/rhevm-api;645e425e-66fe-4ac9-8874-537bd10ef08d' + +require 'vcr' + +VCR.config do |c| + c.cassette_library_dir = "#{File.dirname(__FILE__)}/fixtures/" + c.stub_with :webmock + c.default_cassette_options = { :record => :none } +end diff --git a/server/tests/drivers/rhevm/hardware_profiles_test.rb b/server/tests/drivers/rhevm/hardware_profiles_test.rb index e6323b8..f701fa9 100644 --- a/server/tests/drivers/rhevm/hardware_profiles_test.rb +++ b/server/tests/drivers/rhevm/hardware_profiles_test.rb @@ -1,13 +1,19 @@ $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..') require 'tests/common' +DeltacloudTestCommon.record! module RHEVMTest class HardwareProfilesTest < Test::Unit::TestCase include Rack::Test::Methods def app - Sinatra::Application + Rack::Builder.new { + map '/' do + use Rack::Static, :urls => ["/stylesheets", "/javascripts"], :root => "public" + run Rack::Cascade.new([Deltacloud::API]) + end + } end def test_01_it_returns_hardware_profiles diff --git a/server/tests/drivers/rhevm/images_test.rb b/server/tests/drivers/rhevm/images_test.rb index 0b8a27b..3e9948a 100644 --- a/server/tests/drivers/rhevm/images_test.rb +++ b/server/tests/drivers/rhevm/images_test.rb @@ -1,17 +1,25 @@ $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..') require 'tests/common' +DeltacloudTestCommon.record! + module RHEVMTest class ImagesTest < Test::Unit::TestCase include Rack::Test::Methods def app - Sinatra::Application + Rack::Builder.new { + map '/' do + use Rack::Static, :urls => ["/stylesheets", "/javascripts"], :root => "public" + run Rack::Cascade.new([Deltacloud::API]) + end + } end def test_01_it_returns_images get_auth_url '/api;driver=rhevm/images' + puts last_response.body (last_xml_response/'images/image').length.should > 0 end diff --git a/server/tests/drivers/rhevm/instances_test.rb b/server/tests/drivers/rhevm/instances_test.rb index 1f87a18..179eb98 100644 --- a/server/tests/drivers/rhevm/instances_test.rb +++ b/server/tests/drivers/rhevm/instances_test.rb @@ -1,13 +1,19 @@ $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..') require 'tests/common' +DeltacloudTestCommon.record! module RHEVMTest class InstancesTest < Test::Unit::TestCase include Rack::Test::Methods def app - Sinatra::Application + Rack::Builder.new { + map '/' do + use Rack::Static, :urls => ["/stylesheets", "/javascripts"], :root => "public" + run Rack::Cascade.new([Deltacloud::API]) + end + } end def test_01_01_it_can_create_instance_without_hardware_profile diff --git a/server/tests/drivers/rhevm/realms_test.rb b/server/tests/drivers/rhevm/realms_test.rb index 5f84667..2c90578 100644 --- a/server/tests/drivers/rhevm/realms_test.rb +++ b/server/tests/drivers/rhevm/realms_test.rb @@ -1,13 +1,18 @@ $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..') require 'tests/common' - +DeltacloudTestCommon.record! module RHEVMTest class RealmsTest < Test::Unit::TestCase include Rack::Test::Methods def app - Sinatra::Application + Rack::Builder.new { + map '/' do + use Rack::Static, :urls => ["/stylesheets", "/javascripts"], :root => "public" + run Rack::Cascade.new([Deltacloud::API]) + end + } end def test_01_it_returns_realms diff --git a/server/tests/drivers/rhevm/setup.rb b/server/tests/drivers/rhevm/setup.rb deleted file mode 100644 index 8c58ba2..0000000 --- a/server/tests/drivers/rhevm/setup.rb +++ /dev/null @@ -1,14 +0,0 @@ -ENV['API_USER'] = '[email protected]' -ENV['API_PASSWORD'] = '123456' -ENV['API_PROVIDER'] = 'https://rhev30-dc.lab.eng.brq.redhat.com:8443/rhevm-api;645e425e-66fe-4ac9-8874-537bd10ef08d' - -require 'vcr' - -DeltacloudTestCommon::record! - -VCR.config do |c| - c.cassette_library_dir = "#{File.dirname(__FILE__)}/../../../tests/drivers/rhevm/fixtures/" - c.stub_with :webmock - c.default_cassette_options = { :record => :none } -end - -- 1.7.10.1
