deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 4/4] Core: Tests fixed to use new Deltacloud multifrontend syntax
Date Thu, 07 Jun 2012 11:19:45 GMT
From: Michal Fojtik <mfojtik@redhat.com>


Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 server/tests/drivers/ec2/drivers_test.rb           |    2 +-
 server/tests/drivers/ec2/hardware_profiles_test.rb |    2 +-
 server/tests/drivers/ec2/images_test.rb            |    2 +-
 server/tests/drivers/ec2/instances_test.rb         |    2 +-
 server/tests/drivers/ec2/keys_test.rb              |    2 +-
 server/tests/drivers/ec2/realms_test.rb            |    2 +-
 server/tests/drivers/mock/buckets_test.rb          |    2 +-
 server/tests/drivers/mock/drivers_test.rb          |    2 +-
 .../tests/drivers/mock/hardware_profiles_test.rb   |    2 +-
 server/tests/drivers/mock/images_test.rb           |    2 +-
 server/tests/drivers/mock/instances_test.rb        |    2 +-
 server/tests/drivers/mock/keys_test.rb             |    2 +-
 server/tests/drivers/mock/realms_test.rb           |    2 +-
 .../tests/drivers/mock/storage_snapshots_test.rb   |    2 +-
 server/tests/drivers/mock/storage_volumes_test.rb  |    2 +-
 server/tests/minitest_common.rb                    |   14 +++++-
 server/tests/minitest_common_api_test.rb           |   48 ++++++++++----------
 tests/mock/support/env.rb                          |    4 +-
 18 files changed, 54 insertions(+), 42 deletions(-)

diff --git a/server/tests/drivers/ec2/drivers_test.rb b/server/tests/drivers/ec2/drivers_test.rb
index 4521ca3..dc702c0 100644
--- a/server/tests/drivers/ec2/drivers_test.rb
+++ b/server/tests/drivers/ec2/drivers_test.rb
@@ -13,7 +13,7 @@ describe 'Deltacloud API drivers' do
   end
 
   it 'must advertise have the drivers collection in API entrypoint' do
-    get Deltacloud[:root_url]
+    get root_url
     (xml_response/'api/link[@rel=drivers]').wont_be_empty
   end
 
diff --git a/server/tests/drivers/ec2/hardware_profiles_test.rb b/server/tests/drivers/ec2/hardware_profiles_test.rb
index 1ec1664..23d2876 100644
--- a/server/tests/drivers/ec2/hardware_profiles_test.rb
+++ b/server/tests/drivers/ec2/hardware_profiles_test.rb
@@ -5,7 +5,7 @@ describe 'Deltacloud API Hardware Profiles' do
   include Deltacloud::Test
 
   it 'must advertise have the hardware_profiles collection in API entrypoint' do
-    get Deltacloud[:root_url]
+    get root_url
     (xml_response/'api/link[@rel=hardware_profiles]').wont_be_empty
   end
 
diff --git a/server/tests/drivers/ec2/images_test.rb b/server/tests/drivers/ec2/images_test.rb
index 2529a01..18652a2 100644
--- a/server/tests/drivers/ec2/images_test.rb
+++ b/server/tests/drivers/ec2/images_test.rb
@@ -14,7 +14,7 @@ describe 'Deltacloud API Images' do
   include Deltacloud::Test
 
   it 'must advertise have the images collection in API entrypoint' do
-    get Deltacloud[:root_url]
+    get root_url
     (xml_response/'api/link[@rel=images]').wont_be_empty
   end
 
diff --git a/server/tests/drivers/ec2/instances_test.rb b/server/tests/drivers/ec2/instances_test.rb
index c28fde6..8f91d5f 100644
--- a/server/tests/drivers/ec2/instances_test.rb
+++ b/server/tests/drivers/ec2/instances_test.rb
@@ -14,7 +14,7 @@ describe 'Deltacloud API instances' do
   end
 
   it 'must advertise have the instances collection in API entrypoint' do
-    get Deltacloud[:root_url]
+    get root_url
     (xml_response/'api/link[@rel=instances]').wont_be_empty
   end
 
diff --git a/server/tests/drivers/ec2/keys_test.rb b/server/tests/drivers/ec2/keys_test.rb
index efcdcc5..b499b0c 100644
--- a/server/tests/drivers/ec2/keys_test.rb
+++ b/server/tests/drivers/ec2/keys_test.rb
@@ -15,7 +15,7 @@ describe 'Deltacloud API Keys' do
   include Deltacloud::Test
 
   it 'must advertise have the keys collection in API entrypoint' do
-    get Deltacloud[:root_url]
+    get root_url
     (xml_response/'api/link[@rel=keys]').wont_be_empty
   end
 
diff --git a/server/tests/drivers/ec2/realms_test.rb b/server/tests/drivers/ec2/realms_test.rb
index 9df854b..a43e0aa 100644
--- a/server/tests/drivers/ec2/realms_test.rb
+++ b/server/tests/drivers/ec2/realms_test.rb
@@ -14,7 +14,7 @@ describe 'Deltacloud API Realms' do
   include Deltacloud::Test
 
   it 'must advertise have the realms collection in API entrypoint' do
-    get Deltacloud[:root_url]
+    get root_url
     (xml_response/'api/link[@rel=realms]').wont_be_empty
   end
 
diff --git a/server/tests/drivers/mock/buckets_test.rb b/server/tests/drivers/mock/buckets_test.rb
index b10c5bd..97ef445 100644
--- a/server/tests/drivers/mock/buckets_test.rb
+++ b/server/tests/drivers/mock/buckets_test.rb
@@ -5,7 +5,7 @@ describe 'Deltacloud API buckets' do
   include Deltacloud::Test
 
   it 'must advertise have the buckets collection in API entrypoint' do
-    get Deltacloud[:root_url]
+    get root_url
     (xml_response/'api/link[@rel=buckets]').wont_be_empty
   end
 
diff --git a/server/tests/drivers/mock/drivers_test.rb b/server/tests/drivers/mock/drivers_test.rb
index 537c341..e110446 100644
--- a/server/tests/drivers/mock/drivers_test.rb
+++ b/server/tests/drivers/mock/drivers_test.rb
@@ -5,7 +5,7 @@ describe 'Deltacloud API drivers' do
   include Deltacloud::Test
 
   it 'must advertise have the drivers collection in API entrypoint' do
-    get Deltacloud[:root_url]
+    get root_url
     (xml_response/'api/link[@rel=drivers]').wont_be_empty
   end
 
diff --git a/server/tests/drivers/mock/hardware_profiles_test.rb b/server/tests/drivers/mock/hardware_profiles_test.rb
index 91c7c34..b21f0af 100644
--- a/server/tests/drivers/mock/hardware_profiles_test.rb
+++ b/server/tests/drivers/mock/hardware_profiles_test.rb
@@ -5,7 +5,7 @@ describe 'Deltacloud API Hardware Profiles' do
   include Deltacloud::Test
 
   it 'must advertise have the hardware_profiles collection in API entrypoint' do
-    get Deltacloud[:root_url]
+    get root_url
     (xml_response/'api/link[@rel=hardware_profiles]').wont_be_empty
   end
 
diff --git a/server/tests/drivers/mock/images_test.rb b/server/tests/drivers/mock/images_test.rb
index df866a0..50e653c 100644
--- a/server/tests/drivers/mock/images_test.rb
+++ b/server/tests/drivers/mock/images_test.rb
@@ -5,7 +5,7 @@ describe 'Deltacloud API Images' do
   include Deltacloud::Test
 
   it 'must advertise have the images collection in API entrypoint' do
-    get Deltacloud[:root_url]
+    get root_url
     (xml_response/'api/link[@rel=images]').wont_be_empty
   end
 
diff --git a/server/tests/drivers/mock/instances_test.rb b/server/tests/drivers/mock/instances_test.rb
index f7c8550..d30fb3f 100644
--- a/server/tests/drivers/mock/instances_test.rb
+++ b/server/tests/drivers/mock/instances_test.rb
@@ -5,7 +5,7 @@ describe 'Deltacloud API instances' do
   include Deltacloud::Test
 
   it 'must advertise have the instances collection in API entrypoint' do
-    get Deltacloud[:root_url]
+    get root_url
     (xml_response/'api/link[@rel=instances]').wont_be_empty
   end
 
diff --git a/server/tests/drivers/mock/keys_test.rb b/server/tests/drivers/mock/keys_test.rb
index ef358a5..ed7354f 100644
--- a/server/tests/drivers/mock/keys_test.rb
+++ b/server/tests/drivers/mock/keys_test.rb
@@ -5,7 +5,7 @@ describe 'Deltacloud API Keys' do
   include Deltacloud::Test
 
   it 'must advertise have the keys collection in API entrypoint' do
-    get Deltacloud[:root_url]
+    get root_url
     (xml_response/'api/link[@rel=keys]').wont_be_empty
   end
 
diff --git a/server/tests/drivers/mock/realms_test.rb b/server/tests/drivers/mock/realms_test.rb
index fe6094e..0c254dd 100644
--- a/server/tests/drivers/mock/realms_test.rb
+++ b/server/tests/drivers/mock/realms_test.rb
@@ -5,7 +5,7 @@ describe 'Deltacloud API Realms' do
   include Deltacloud::Test
 
   it 'must advertise have the realms collection in API entrypoint' do
-    get Deltacloud[:root_url]
+    get root_url
     (xml_response/'api/link[@rel=realms]').wont_be_empty
   end
 
diff --git a/server/tests/drivers/mock/storage_snapshots_test.rb b/server/tests/drivers/mock/storage_snapshots_test.rb
index 8676d14..957e500 100644
--- a/server/tests/drivers/mock/storage_snapshots_test.rb
+++ b/server/tests/drivers/mock/storage_snapshots_test.rb
@@ -5,7 +5,7 @@ describe 'Deltacloud API storage_snapshots' do
   include Deltacloud::Test
 
   it 'must advertise have the storage_snapshots collection in API entrypoint' do
-    get Deltacloud[:root_url]
+    get root_url
     (xml_response/'api/link[@rel=storage_snapshots]').wont_be_empty
   end
 
diff --git a/server/tests/drivers/mock/storage_volumes_test.rb b/server/tests/drivers/mock/storage_volumes_test.rb
index 62c9159..98682ad 100644
--- a/server/tests/drivers/mock/storage_volumes_test.rb
+++ b/server/tests/drivers/mock/storage_volumes_test.rb
@@ -5,7 +5,7 @@ describe 'Deltacloud API storage_volumes' do
   include Deltacloud::Test
 
   it 'must advertise have the storage_volumes collection in API entrypoint' do
-    get Deltacloud[:root_url]
+    get root_url
     (xml_response/'api/link[@rel=storage_volumes]').wont_be_empty
   end
 
diff --git a/server/tests/minitest_common.rb b/server/tests/minitest_common.rb
index 0fbfe9b..7fc0824 100644
--- a/server/tests/minitest_common.rb
+++ b/server/tests/minitest_common.rb
@@ -4,7 +4,9 @@ Deltacloud::configure do |server|
   server.root_url '/api'
   server.version '0.5.0'
   server.klass 'Deltacloud::API'
-end.require_frontend!
+end
+
+Deltacloud.require_frontend!(:deltacloud)
 
 require 'minitest/autorun'
 require 'rack/test'
@@ -28,12 +30,20 @@ module Deltacloud
       Nokogiri::XML(last_response.body)
     end
 
+    def root_url
+      Deltacloud[:deltacloud].root_url
+    end
+
+    def api_version
+      Deltacloud[:deltacloud].version
+    end
+
     def authenticate
       authorize ENV['TESTS_API_USERNAME'], ENV['TESTS_API_PASSWORD']
     end
 
     def collection_url(collection)
-      [Deltacloud[:root_url], collection.to_s].join('/')
+      [root_url, collection.to_s].join('/')
     end
 
     def app
diff --git a/server/tests/minitest_common_api_test.rb b/server/tests/minitest_common_api_test.rb
index 21d18f7..fb2591b 100644
--- a/server/tests/minitest_common_api_test.rb
+++ b/server/tests/minitest_common_api_test.rb
@@ -2,37 +2,37 @@
 #used across all drivers. See /drivers/*/api_test.rb
 
   it 'return HTTP_OK when accessing API entrypoint' do
-    get Deltacloud[:root_url]
+    get root_url
     last_response.status.must_equal 200
   end
 
   it 'advertise the current driver in API entrypoint' do
-    get Deltacloud[:root_url]
+    get root_url
     xml_response.root[:driver].must_equal ENV['API_DRIVER']
   end
 
   it 'advertise the current API version in API entrypoint' do
-    get Deltacloud[:root_url]
-    xml_response.root[:version].must_equal Deltacloud[:version]
+    get root_url
+    xml_response.root[:version].must_equal api_version
   end
 
   it 'advertise the current API version in HTTP headers' do
-    get Deltacloud[:root_url]
-    last_response.headers['Server'].must_equal "Apache-Deltacloud/#{Deltacloud[:version]}"
+    get root_url
+    last_response.headers['Server'].must_equal "Apache-Deltacloud/#{api_version}"
   end
 
   it 'must include the ETag in HTTP headers' do
-    get Deltacloud[:root_url]
+    get root_url
     last_response.headers['ETag'].wont_be_nil
   end
 
   it 'advertise collections in API entrypoint' do
-    get Deltacloud[:root_url]
+    get root_url
     (xml_response/'api/link').wont_be_empty
   end
 
   it 'include the :href and :rel attribute for each collection in API entrypoint' do
-    get Deltacloud[:root_url]
+    get root_url
     (xml_response/'api/link').each do |collection|
       collection[:href].wont_be_nil
       collection[:rel].wont_be_nil
@@ -40,19 +40,19 @@
   end
 
   it 'uses the absolute URI in the :href attribute for each collection in API entrypoint'
do
-    get Deltacloud[:root_url]
+    get root_url
     (xml_response/'api/link').each do |collection|
       collection[:href].must_match /^http/
     end
   end
 
   it 'advertise features for some collections in API entrypoint' do
-    get Deltacloud[:root_url]
+    get root_url
     (xml_response/'api/link/feature').wont_be_empty
   end
 
   it 'advertise the name of the feature for some collections in API entrypoint' do
-    get Deltacloud[:root_url]
+    get root_url
     (xml_response/'api/link/feature').each do |f|
       f[:name].wont_be_nil
     end
@@ -60,55 +60,55 @@
 
   it 'must change the media type from XML to JSON using Accept headers' do
     header 'Accept', 'application/json'
-    get Deltacloud[:root_url]
+    get root_url
     last_response.headers['Content-Type'].must_equal 'application/json'
   end
 
   it 'must change the media type to JSON using the "?format" parameter in URL' do
-    get Deltacloud[:root_url], { :format => 'json' }
+    get root_url, { :format => 'json' }
     last_response.headers['Content-Type'].must_equal 'application/json'
   end
 
   it 'must change the driver when using X-Deltacloud-Driver HTTP header' do
     header 'X-Deltacloud-Driver', 'ec2'
-    get Deltacloud[:root_url]
+    get root_url
     xml_response.root[:driver].must_equal 'ec2'
     header 'X-Deltacloud-Driver', 'mock'
-    get Deltacloud[:root_url]
+    get root_url
     xml_response.root[:driver].must_equal 'mock'
   end
 
   it 'must change the features when driver is swapped using HTTP headers' do
     header 'X-Deltacloud-Driver', 'ec2'
-    get Deltacloud[:root_url]
+    get root_url
     # The 'user_name' feature is not supported currently for the EC2 driver
     (xml_response/'api/link/feature').map { |f| f[:name] }.wont_include 'user_name'
     header 'X-Deltacloud-Driver', 'mock'
-    get Deltacloud[:root_url]
+    get root_url
     # But it's supported in Mock driver
     (xml_response/'api/link/feature').map { |f| f[:name] }.must_include 'user_name'
   end
 
   it 'must re-validate the driver credentials when using "?force_auth" parameter in URL'
do
-    get Deltacloud[:root_url], { :force_auth => '1' }
+    get root_url, { :force_auth => '1' }
     last_response.status.must_equal 401
     authenticate
-    get Deltacloud[:root_url], { :force_auth => '1' }
+    get root_url, { :force_auth => '1' }
     last_response.status.must_equal 200
   end
 
   it 'must change the API PROVIDER using the /api;provider matrix parameter in URI' do
-    get Deltacloud[:root_url] + ';provider=test1'
+    get root_url + ';provider=test1'
     xml_response.root[:provider].wont_be_nil
     xml_response.root[:provider].must_equal 'test1'
-    get Deltacloud[:root_url] + ';provider=test2'
+    get root_url + ';provider=test2'
     xml_response.root[:provider].must_equal 'test2'
   end
 
   it 'must change the API DRIVER using the /api;driver matrix parameter in URI' do
-    get Deltacloud[:root_url] + ';driver=ec2'
+    get root_url + ';driver=ec2'
     xml_response.root[:driver].must_equal 'ec2'
-    get Deltacloud[:root_url] + ';driver=mock'
+    get root_url + ';driver=mock'
     xml_response.root[:driver].must_equal 'mock'
   end
 
diff --git a/tests/mock/support/env.rb b/tests/mock/support/env.rb
index 8b2581f..9365498 100644
--- a/tests/mock/support/env.rb
+++ b/tests/mock/support/env.rb
@@ -7,7 +7,9 @@ Deltacloud::configure do |server|
   server.root_url '/api'
   server.version '0.5.0'
   server.klass 'Deltacloud::API'
-end.require_frontend!
+end
+
+Deltacloud.require_frontend!(:deltacloud)
 
 CONFIG = {
   :username => 'mockuser',
-- 
1.7.10.2


Mime
View raw message