deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [29/30] git commit: Client: Complete revamp of deltacloud-client unit tests
Date Tue, 26 Mar 2013 17:58:15 GMT
Client: Complete revamp of deltacloud-client unit tests

- Use minitest instead of rspec
- Use VCR by default for tests (rake test_live override this)
- Coverage >90%


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/3d865944
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/3d865944
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/3d865944

Branch: refs/heads/master
Commit: 3d865944ac1c8434c78e7b0efd62df57c2251ce3
Parents: 71afec5
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Thu Mar 7 13:47:37 2013 +0100
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Tue Mar 26 15:21:35 2013 +0100

----------------------------------------------------------------------
 client/tests/buckets_test.rb                       |  141 ----------
 client/tests/client/client_test.rb                 |   51 ++++
 client/tests/client/connection_test.rb             |   77 ++++++
 client/tests/client_test.rb                        |   59 -----
 client/tests/content_negotiation_test.rb           |  127 ---------
 client/tests/core_ext/element_test.rb              |   40 +++
 client/tests/core_ext/fixnum_test.rb               |   35 +++
 client/tests/core_ext/nil.rb                       |   27 ++
 client/tests/core_ext/string_test.rb               |   47 ++++
 client/tests/errors_test.rb                        |   57 ----
 client/tests/hardware_profiles_test.rb             |   75 ------
 client/tests/helpers/model_test.rb                 |   33 +++
 client/tests/helpers/xml_test.rb                   |   56 ++++
 client/tests/images_test.rb                        |  102 --------
 client/tests/instance_states_test.rb               |   66 -----
 client/tests/instances_test.rb                     |  203 ---------------
 client/tests/keys_test.rb                          |   81 ------
 client/tests/methods/address_test.rb               |   64 +++++
 client/tests/methods/api_test.rb                   |   97 +++++++
 .../tests/methods/backward_compatibility_test.rb   |   87 ++++++
 client/tests/methods/blob_test.rb                  |   64 +++++
 client/tests/methods/bucket_test.rb                |   62 +++++
 client/tests/methods/driver_test.rb                |   48 ++++
 client/tests/methods/firewall_test.rb              |   84 ++++++
 client/tests/methods/hardware_profile_test.rb      |   53 ++++
 client/tests/methods/image_test.rb                 |   64 +++++
 client/tests/methods/instance_state_test.rb        |   43 +++
 client/tests/methods/instance_test.rb              |  120 +++++++++
 client/tests/methods/key_test.rb                   |   63 +++++
 client/tests/methods/realm_test.rb                 |   50 ++++
 client/tests/methods/storage_snapshot_test.rb      |   53 ++++
 client/tests/methods/storage_volume_test.rb        |   81 ++++++
 client/tests/models/blob_test.rb                   |   40 +++
 client/tests/models/bucket_test.rb                 |   37 +++
 client/tests/models/driver_test.rb                 |   42 +++
 client/tests/models/hardware_profile_test.rb       |   80 ++++++
 client/tests/models/image_test.rb                  |   63 +++++
 client/tests/models/storage_volume_test.rb         |   52 ++++
 client/tests/realms_test.rb                        |   64 -----
 client/tests/storage_snapshot_test.rb              |   76 ------
 client/tests/storage_volume_test.rb                |   86 ------
 client/tests/test_helper.rb                        |   70 +++++-
 42 files changed, 1772 insertions(+), 1148 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3d865944/client/tests/buckets_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/buckets_test.rb b/client/tests/buckets_test.rb
deleted file mode 100644
index 5ef6969..0000000
--- a/client/tests/buckets_test.rb
+++ /dev/null
@@ -1,141 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.  The
-# ASF licenses this file to you 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 'rubygems'
-require 'require_relative' if RUBY_VERSION =~ /^1\.8/
-
-require_relative './test_helper.rb'
-
-describe "Buckets" do
-
-  it "should allow retrieval of all buckets" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      buckets = client.buckets
-      buckets.wont_be_empty
-      buckets.each do |bucket|
-        bucket.uri.wont_be_nil
-        bucket.uri.must_be_kind_of String
-        bucket.name.wont_be_nil
-        bucket.name.must_be_kind_of String
-      end
-    end
-  end
-
-  it "should allow retrieval of a named bucket" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      bucket = client.bucket("bucket1")
-      bucket.wont_be_nil
-      bucket.uri.must_equal API_URL + "/buckets/bucket1"
-      bucket.size.must_equal 3.0
-      bucket.name.wont_be_nil
-      bucket.name.must_be_kind_of String
-      blob_list = bucket.blob_list.split(", ")
-      blob_list.size.must_equal bucket.size.to_i
-    end
-  end
-
-end
-
-describe "Operations on buckets" do
-
-  it "should allow creation of a new bucket" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      new_bucket = client.create_bucket({'id' => "my_new_bucket"})
-      new_bucket.wont_be_nil
-      new_bucket.uri.must_equal API_URL + "/buckets/my_new_bucket"
-      new_bucket.name.wont_be_nil
-      new_bucket.name.must_be_kind_of String
-      new_bucket.name.must_equal "my_new_bucket"
-    end
-  end
-
-  it "should allow deletion of an existing bucket" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      new_bucket = client.bucket("my_new_bucket")
-      new_bucket.wont_be_nil
-      new_bucket.name.must_equal "my_new_bucket"
-      client.destroy_bucket('id' => "my_new_bucket").must_be_nil
-    end
-  end
-
-  it "should throw error if you delete a non existing bucket" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      lambda {
-      client.destroy_bucket({'id' => "i_dont_exist"}).must_be_nil
-      }.must_raise DeltaCloud::HTTPError::DeltacloudError
-    end
-  end
-
-end
-
-describe "Blobs" do
-
-  it "should allow retrieval of a bucket's blobs" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      bucket = client.bucket("bucket1")
-      bucket.wont_be_nil
-      blob_list = bucket.blob_list.split(", ")
-      blob_list.size.must_equal bucket.size.to_i
-      blob_list.each do |b_id|
-        blob = client.blob("bucket" => bucket.name, :id => b_id)
-        blob.bucket.wont_be_nil
-        blob.bucket.must_be_kind_of String
-        blob.bucket.must_equal bucket.name
-        blob.content_length.wont_be_nil
-        blob.content_length.must_be_kind_of Float
-        blob.content_length.must_be :'>=', 0
-        blob_data = client.blob_data("bucket" => bucket.name, :id => b_id)
-        blob_data.size.to_f.must_equal blob.content_length
-        blob.last_modified.wont_be_nil
-      end
-    end
-  end
-
-end
-
-describe "Operations on blobs" do
-
-  it "should successfully create a new blob" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      blob_data = File.new("./blob_data_file", "w+")
-      blob_data.write("this is some blob data \n")
-      blob_data.rewind
-      some_new_blob = client.create_blob(
-        :id => "some_new_blob",
-        'bucket' => "bucket1",
-        'file_path' => blob_data.path
-      )
-      some_new_blob.wont_be_nil
-      some_new_blob.content_length.wont_be_nil
-      some_new_blob.content_length.must_equal 24.0
-      File.delete(blob_data.path)
-    end
-  end
-
-  it "should allow deletion of an existing blob" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      client.destroy_blob(:id=>"some_new_blob", 'bucket'=>"bucket1").must_be_nil
-    end
-  end
-
-  it "should throw error if you delete a non existing blob" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      lambda {
-        client.destroy_blob(:id=>"no_such_blob", 'bucket'=>"bucket1").must_be_nil
-      }.must_raise DeltaCloud::HTTPError::DeltacloudError
-    end
-  end
-
-end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3d865944/client/tests/client/client_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/client/client_test.rb b/client/tests/client/client_test.rb
new file mode 100644
index 0000000..1502acc
--- /dev/null
+++ b/client/tests/client/client_test.rb
@@ -0,0 +1,51 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you 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_relative '../test_helper'
+
+describe Deltacloud::Client do
+
+  before do
+    VCR.insert_cassette(__name__)
+  end
+
+  after do
+    VCR.eject_cassette
+  end
+
+  it 'support #VERSION' do
+    Deltacloud::Client::VERSION.wont_be_nil
+  end
+
+  it 'support #Client' do
+    Deltacloud.must_respond_to 'Client'
+  end
+
+  it 'support to change driver with #Client' do
+    client = Deltacloud::Client(
+      DELTACLOUD_URL, DELTACLOUD_USER, DELTACLOUD_PASSWORD,
+      :driver => :ec2
+    )
+    client.request_driver.must_equal :ec2
+    client.current_driver.must_equal 'ec2'
+  end
+
+  it 'support to test of valid DC connection' do
+    Deltacloud::Client.must_respond_to 'valid_connection?'
+    Deltacloud::Client.valid_connection?(DELTACLOUD_URL).must_equal true
+    Deltacloud::Client.valid_connection?('http://unknown:9999').must_equal false
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3d865944/client/tests/client/connection_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/client/connection_test.rb b/client/tests/client/connection_test.rb
new file mode 100644
index 0000000..6833ed1
--- /dev/null
+++ b/client/tests/client/connection_test.rb
@@ -0,0 +1,77 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you 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_relative '../test_helper'
+
+describe Deltacloud::Client::Connection do
+
+  before do
+    VCR.insert_cassette(__name__)
+  end
+
+  after do
+    VCR.eject_cassette
+  end
+
+  it 'connects to Deltacloud API' do
+    client = new_client
+    client.connection.wont_be_nil
+    client.connection.must_be_kind_of Faraday::Connection
+    client.version.wont_be_nil
+  end
+
+  it 'supports #version' do
+    client = new_client
+    client.must_respond_to :version
+    client.version.wont_be_nil
+    client.version.wont_be_empty
+  end
+
+  it 'caches the API entrypoint' do
+    client = new_client
+    client.cache_entrypoint!.wont_be_nil
+  end
+
+  it 'supports #valid_credentials?' do
+    client = new_client
+    client.must_respond_to :"valid_credentials?"
+    client.valid_credentials?.must_equal true
+    client = Deltacloud::Client(DELTACLOUD_URL, 'foo', 'bar')
+    client.valid_credentials?.must_equal false
+  end
+
+  it 'supports switching drivers per instance' do
+    client = new_client
+    client.current_driver.must_equal 'mock'
+    ec2_client = client.use(:ec2, 'foo', 'bar')
+    ec2_client.current_driver.must_equal 'ec2'
+    client.current_driver.must_equal 'mock'
+  end
+
+  it 'supports switching providers per instance' do
+    client = new_client
+    ec2_client = client.use(:ec2, 'foo', 'bar', 'eu-west-1')
+    ec2_client.current_provider.must_equal 'eu-west-1'
+    ec2_client = client.use(:ec2, 'foo', 'bar', 'us-east-1')
+    ec2_client.current_provider.must_equal 'us-east-1'
+  end
+
+  it 'support switching provider without credentials' do
+    client = new_client.use(:ec2, 'foo', 'bar', 'eu-west-1')
+    new_provider = client.use_provider('us-east-1')
+    new_provider.current_provider.must_equal 'us-east-1'
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3d865944/client/tests/client_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/client_test.rb b/client/tests/client_test.rb
deleted file mode 100644
index 59c39db..0000000
--- a/client/tests/client_test.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.  The
-# ASF licenses this file to you 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 'rubygems'
-require 'require_relative' if RUBY_VERSION =~ /^1\.8/
-
-require_relative './test_helper.rb'
-
-describe "initializing the client" do
-
-  it "should parse valid API URIs" do
-    client = DeltaCloud.new( API_NAME, API_PASSWORD, API_URL )
-    client.api_host.must_equal API_HOST
-    client.api_port.must_equal API_PORT.to_i
-    client.api_path.must_equal API_PATH
-  end
-
-  it "should discover entry points upon connection" do
-    DeltaCloud.new( "name", "password", API_URL ) do |client|
-      client.entry_points[:hardware_profiles].must_equal "#{API_URL}/hardware_profiles"
-      client.entry_points[:images].must_equal "#{API_URL}/images"
-      client.entry_points[:instances].must_equal "#{API_URL}/instances"
-      client.entry_points[:storage_volumes].must_equal "#{API_URL}/storage_volumes"
-      client.entry_points[:storage_snapshots].must_equal "#{API_URL}/storage_snapshots"
-      client.entry_points[:buckets].must_equal "#{API_URL}/buckets"
-      client.entry_points[:keys].must_equal "#{API_URL}/keys"
-    end
-  end
-
-  it "should provide the current driver name via client" do
-    DeltaCloud.new( "name", "password", API_URL ) do |client|
-      client.driver_name.must_equal 'mock'
-    end
-  end
-
-  it "should provide the current driver name without client" do
-    DeltaCloud.driver_name( API_URL ).must_equal 'mock'
-  end
-
-  describe "without a block" do
-    it "should connect without a block" do
-      client = DeltaCloud.new( API_NAME, API_PASSWORD, API_URL )
-      client.images.wont_be_nil
-    end
-  end
-
-end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3d865944/client/tests/content_negotiation_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/content_negotiation_test.rb b/client/tests/content_negotiation_test.rb
deleted file mode 100644
index 60c90c0..0000000
--- a/client/tests/content_negotiation_test.rb
+++ /dev/null
@@ -1,127 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.  The
-# ASF licenses this file to you 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 'rubygems'
-require 'require_relative' if RUBY_VERSION =~ /^1\.8/
-
-require_relative './test_helper.rb'
-
-def client; RestClient::Resource.new(API_URL); end
-
-def headers(header)
-  encoded_credentials = ["#{API_NAME}:#{API_PASSWORD}"].pack("m0").gsub(/\n/,'')
-  { :authorization => "Basic " + encoded_credentials }.merge(header)
-end
-
-describe "return JSON" do
-
-  it 'should return JSON when using application/json, */*' do
-    header_hash = {
-      # FIXME: There is a bug in rack-accept that cause to respond with HTML
-      # to the configuration below.
-      #
-      # 'Accept' => "application/json, */*"
-      'Accept' => "application/json"
-    }
-    client.get(header_hash) do |response, request, &block|
-      response.code.must_equal 200
-      response.headers[:content_type].must_match /^application\/json/
-    end
-  end
-
-  it 'should return JSON when using just application/json' do
-    header_hash = {
-      'Accept' => "application/json"
-    }
-    client.get(header_hash) do |response, request, &block|
-      response.code.must_equal 200
-      response.headers[:content_type].must_match /^application\/json/
-    end
-  end
-
-end
-
-describe "return HTML in different browsers" do
-
-  it "wants XML using format parameter" do
-    client.get(:params => { 'format' => 'xml' }, 'Accept' => 'application/xhtml+xml') do |response, request, &block|
-      response.code.must_equal 200
-      response.headers[:content_type].must_match /^application\/xml/
-    end
-  end
-
-  it "raise 406 error on wrong accept" do
-    client['hardware_profiles'].get('Accept' => 'image/png;q=1') do |response, request, &block|
-      response.code.must_equal 406
-    end
-  end
-
-  it "wants HTML using format parameter and accept set to XML" do
-    client.get(:params => { 'format' => 'html'}, 'Accept' => 'application/xml') do |response, request, &block|
-      response.code.must_equal 200
-      response.headers[:content_type].must_match /^text\/html/
-    end
-  end
-
-  it "doesn't have accept header" do
-    client.get('Accept' => '') do |response, request, &block|
-      response.code.must_equal 200
-      response.headers[:content_type].must_match /^application\/xml/
-    end
-  end
-
-  it "can handle unknown formats" do
-    client.get('Accept' => 'format/unknown') do |response, request, &block|
-      response.code.must_equal 406
-    end
-  end
-
-  it "wants explicitly XML" do
-    client.get('Accept' => 'application/xml') do |response, request, &block|
-      response.code.must_equal 200
-      response.headers[:content_type].must_match /^application\/xml/
-    end
-  end
-
-  it "Internet Explorer" do
-    header_hash = {
-      'Accept' => "image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*",
-      'User-agent' => "Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)"
-    }
-    client.get(header_hash) do |response, request, &block|
-      response.code.must_equal 200
-      response.headers[:content_type].must_match /^text\/html/
-    end
-  end
-
-  it "Mozilla Firefox" do
-    client.get('Accept' => "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") do |response, request, &block|
-      response.code.must_equal 200
-      response.headers[:content_type].must_match /^text\/html/
-    end
-  end
-
-  it "Opera" do
-    header_hash = { 
-      'Accept' => "text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1",
-      'User-agent' => "Opera/9.80 (X11; Linux i686; U; ru) Presto/2.8.131 Version/11.11"
-    }
-    client.get(header_hash) do |response, request, &block|
-      response.code.must_equal 200
-      response.headers[:content_type].must_match /^text\/html/
-    end
-  end
-
-end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3d865944/client/tests/core_ext/element_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/core_ext/element_test.rb b/client/tests/core_ext/element_test.rb
new file mode 100644
index 0000000..b354d95
--- /dev/null
+++ b/client/tests/core_ext/element_test.rb
@@ -0,0 +1,40 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you 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_relative '../test_helper'
+
+describe Nokogiri::XML::Element do
+
+  before do
+    mock_xml = Nokogiri::XML(
+      '<root><test id="1"><inner id="2">VALUE</inner><r></r></test></root>'
+    )
+    @mock_el = mock_xml.root
+  end
+
+  it 'support #text_at' do
+    @mock_el.text_at('test/inner').must_equal 'VALUE'
+    @mock_el.text_at('test/unknown').must_be_nil
+    @mock_el.text_at('test/r').must_equal ''
+  end
+
+  it 'support #attr_at' do
+    @mock_el.attr_at('test', :id).must_equal '1'
+    @mock_el.attr_at('test', 'id').must_equal '1'
+    @mock_el.attr_at('test/inner', 'id').must_equal '2'
+    @mock_el.attr_at('r', 'id').must_be_nil
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3d865944/client/tests/core_ext/fixnum_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/core_ext/fixnum_test.rb b/client/tests/core_ext/fixnum_test.rb
new file mode 100644
index 0000000..baba10c
--- /dev/null
+++ b/client/tests/core_ext/fixnum_test.rb
@@ -0,0 +1,35 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you 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_relative '../test_helper'
+
+describe Fixnum do
+
+  it 'support #is_redirect?' do
+    300.must_respond_to :"is_redirect?"
+    300.is_redirect?.must_equal true
+    310.is_redirect?.must_equal true
+    399.is_redirect?.must_equal true
+    510.is_redirect?.must_equal false
+  end
+
+  it 'support #is_ok?' do
+    200.must_respond_to :"is_ok?"
+    200.is_ok?.must_equal true
+    210.is_ok?.must_equal true
+    299.is_ok?.must_equal true
+    510.is_ok?.must_equal false
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3d865944/client/tests/core_ext/nil.rb
----------------------------------------------------------------------
diff --git a/client/tests/core_ext/nil.rb b/client/tests/core_ext/nil.rb
new file mode 100644
index 0000000..ad61dd7
--- /dev/null
+++ b/client/tests/core_ext/nil.rb
@@ -0,0 +1,27 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you 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_relative '../test_helper'
+
+describe Nil do
+
+  it 'support #to_xml' do
+    nil.must_respond_to :to_xml
+    lambda {
+      nil.to_xml
+    }.must_raise Deltacloud::Client::InvalidXMLError
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3d865944/client/tests/core_ext/string_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/core_ext/string_test.rb b/client/tests/core_ext/string_test.rb
new file mode 100644
index 0000000..3a55afc
--- /dev/null
+++ b/client/tests/core_ext/string_test.rb
@@ -0,0 +1,47 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you 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_relative '../test_helper'
+
+describe String do
+
+  it 'support #to_xml' do
+    "".must_respond_to :to_xml
+    "<root></root>".to_xml.must_be_kind_of Nokogiri::XML::Document
+    "<root></root>".to_xml.root.must_be_kind_of Nokogiri::XML::Element
+    "<root></root>".to_xml.root.name.must_equal 'root'
+  end
+
+  it 'support #camelize' do
+    "".must_respond_to :camelize
+    "test".camelize.must_equal 'Test'
+    "foo_bar".camelize.must_equal 'FooBar'
+  end
+
+  it 'support #pluralize' do
+    ''.must_respond_to :pluralize
+    "test".pluralize.must_equal 'tests'
+    "address".pluralize.must_equal 'addresses'
+    "entity".pluralize.must_equal 'entities'
+  end
+
+  it 'support #singularize' do
+    ''.must_respond_to :singularize
+    'tests'.singularize.must_equal 'test'
+    'addresses'.singularize.must_equal 'address'
+    'entity'.singularize.must_equal 'entity'
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3d865944/client/tests/errors_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/errors_test.rb b/client/tests/errors_test.rb
deleted file mode 100644
index 7b8347b..0000000
--- a/client/tests/errors_test.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.  The
-# ASF licenses this file to you 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 'rubygems'
-require 'require_relative' if RUBY_VERSION =~ /^1\.8/
-
-require_relative './test_helper.rb'
-
-describe "server error handler" do
-
-  it 'should capture HTTP 500 error as DeltacloudError' do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      lambda { client.realm('500') }.must_raise DeltaCloud::HTTPError::DeltacloudError
-    end
-  end
-
-  it 'should capture HTTP 502 error as ProviderError' do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      lambda { client.realm('502') }.must_raise DeltaCloud::HTTPError::ProviderError
-    end
-  end
-
-  it 'should capture HTTP 501 error as NotImplemented' do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      lambda { client.realm('501') }.must_raise DeltaCloud::HTTPError::NotImplemented
-    end
-  end
-
-  it 'should capture HTTP 504 error as ProviderTimeout' do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      lambda { client.realm('504') }.must_raise DeltaCloud::HTTPError::ProviderTimeout
-    end
-  end
-
-end
-
-describe "client error handler" do
-
-  it 'should capture HTTP 404 error as NotFound' do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      lambda { client.realm('non-existing-realm') }.must_raise DeltaCloud::HTTPError::NotFound
-    end
-  end
-
-end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3d865944/client/tests/hardware_profiles_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/hardware_profiles_test.rb b/client/tests/hardware_profiles_test.rb
deleted file mode 100644
index b0ae60e..0000000
--- a/client/tests/hardware_profiles_test.rb
+++ /dev/null
@@ -1,75 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.  The
-# ASF licenses this file to you 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 'rubygems'
-require 'require_relative' if RUBY_VERSION =~ /^1\.8/
-
-require_relative './test_helper.rb'
-
-def prop_check(prop, value_class)
-  if prop.present?
-    prop.value.wont_be_nil
-    prop.value.must_be_kind_of value_class
-  end
-end
-
-describe "Hardware Profiles" do
-
-  it "should allow retrieval of all hardware profiles" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      hardware_profiles = client.hardware_profiles
-      hardware_profiles.wont_be_empty
-      hardware_profiles.each do |hwp|
-        hwp.uri.wont_be_nil
-        hwp.uri.must_be_kind_of String
-        prop_check(hwp.architecture, String) unless hwp.name.eql?("opaque")
-     end
-    end
-  end
-
-  it "should allow filtering of hardware_profiles by architecture" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      hardware_profiles = client.hardware_profiles( :architecture=>'i386' )
-      hardware_profiles.wont_be_empty
-      hardware_profiles.size.must_equal 1
-      hardware_profiles.first.architecture.value.must_equal 'i386'
-    end
-  end
-
-  it "should allow fetching a hardware_profile by id" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      hwp = client.hardware_profile( 'm1-small' )
-      hwp.wont_be_nil
-      hwp.id.must_equal 'm1-small'
-    end
-  end
-
-  it "should allow fetching different hardware_profiles" do
-    client = DeltaCloud.new( API_NAME, API_PASSWORD, API_URL )
-    hwp1 = client.hardware_profile( 'm1-small' )
-    hwp2 = client.hardware_profile( 'm1-large' )
-    hwp1.storage.value.wont_equal hwp2.storage.value
-    hwp1.memory.value.wont_equal hwp2.memory.value
-  end
-
-  it "should allow fetching a hardware_profile by URI" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      hwp = client.fetch_hardware_profile( API_URL + '/hardware_profiles/m1-small' )
-      hwp.wont_be_nil
-      hwp.id.must_equal 'm1-small'
-    end
-  end
-
-end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3d865944/client/tests/helpers/model_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/helpers/model_test.rb b/client/tests/helpers/model_test.rb
new file mode 100644
index 0000000..fd42522
--- /dev/null
+++ b/client/tests/helpers/model_test.rb
@@ -0,0 +1,33 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you 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_relative '../test_helper'
+
+describe Deltacloud::Client::Helpers::Model do
+
+  include Deltacloud::Client::Helpers::Model
+
+  it 'supports #model' do
+    model(:error).must_equal Deltacloud::Client::Error
+    model('error').must_equal Deltacloud::Client::Error
+    lambda { model(nil) }.must_raise Deltacloud::Client::Error
+  end
+
+  it 'supports #error' do
+    error.must_equal Deltacloud::Client::Error
+    error(:not_supported).must_equal Deltacloud::Client::NotSupported
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3d865944/client/tests/helpers/xml_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/helpers/xml_test.rb b/client/tests/helpers/xml_test.rb
new file mode 100644
index 0000000..6feb1fc
--- /dev/null
+++ b/client/tests/helpers/xml_test.rb
@@ -0,0 +1,56 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you 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_relative '../test_helper'
+
+describe Deltacloud::Client::Helpers::XmlHelper do
+
+  include Deltacloud::Client::Helpers::XmlHelper
+
+  before do
+    VCR.insert_cassette(__name__)
+  end
+
+  after do
+    VCR.eject_cassette
+  end
+
+  it 'supports #extract_xml_body using string' do
+    extract_xml_body("test").must_be_kind_of String
+  end
+
+  it 'supports #extract_xml_body using faraday connection' do
+    result = extract_xml_body(new_client.connection.get('/api'))
+    result.must_be_kind_of String
+    result.wont_be_empty
+  end
+
+  it 'supports #extract_xml_body using nokogiri::document' do
+    result = extract_xml_body(
+      Nokogiri::XML(new_client.connection.get('/api').body)
+    )
+    result.must_be_kind_of String
+    result.wont_be_empty
+  end
+
+  it 'supports #extract_xml_body using nokogiri::element' do
+    result = extract_xml_body(
+      Nokogiri::XML(new_client.connection.get('/api').body).root
+    )
+    result.must_be_kind_of String
+    result.wont_be_empty
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3d865944/client/tests/images_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/images_test.rb b/client/tests/images_test.rb
deleted file mode 100644
index 91cc961..0000000
--- a/client/tests/images_test.rb
+++ /dev/null
@@ -1,102 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.  The
-# ASF licenses this file to you 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 'rubygems'
-require 'require_relative' if RUBY_VERSION =~ /^1\.8/
-
-require_relative './test_helper.rb'
-
-describe "Images" do
-
-  it "should allow retrieval of all images" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      images = client.images
-      images.wont_be_empty
-      images.size.must_equal 3
-      images.each do |image|
-        image.uri.wont_be_nil
-        image.uri.must_be_kind_of String
-        image.description.wont_be_nil
-        image.description.must_be_kind_of String
-        image.architecture.wont_be_nil
-        image.architecture.must_be_kind_of String
-        image.owner_id.wont_be_nil
-        image.owner_id.must_be_kind_of String
-      end
-    end
-  end
-
-  it "should allow retrieval of my own images" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      images = client.images( :owner_id=>:self )
-      images.wont_be_empty
-      images.size.must_equal 1
-      images.each do |image|
-        image.uri.wont_be_nil
-        image.uri.must_be_kind_of String
-        image.description.wont_be_nil
-        image.description.must_be_kind_of String
-        image.architecture.wont_be_nil
-        image.architecture.must_be_kind_of String
-        image.owner_id.wont_be_nil
-        image.owner_id.must_be_kind_of String
-      end
-    end
-  end
-
-  it "should allow retrieval of a single image by ID" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      image = client.image( 'img1' )
-      image.wont_be_nil
-      image.uri.must_equal API_URL + '/images/img1'
-      image.id.must_equal 'img1'
-      image.architecture.must_equal 'x86_64'
-    end
-  end
-
-  it "should allow retrieval of a single image by URI" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      image = client.fetch_image( API_URL + '/images/img1' )
-      image.wont_be_nil
-      image.uri.must_equal API_URL + '/images/img1'
-      image.id.must_equal 'img1'
-      image.architecture.must_equal 'x86_64'
-    end
-  end
-
-  describe "filtering by architecture" do
-    it "return matching images" do
-      DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-        images = client.images( :architecture=>'x86_64' )
-        images.wont_be_empty
-        images.each do |image|
-          image.architecture.must_equal 'x86_64'
-        end
-        images = client.images( :architecture=>'i386' )
-        images.wont_be_empty
-        images.each do |image|
-          image.architecture.must_equal 'i386'
-        end
-      end
-    end
-
-    it "should return an empty array for no matches" do
-      DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-        images = client.images( :architecture=>'8088' )
-        images.must_be_empty
-      end
-    end
-  end
-end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3d865944/client/tests/instance_states_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/instance_states_test.rb b/client/tests/instance_states_test.rb
deleted file mode 100644
index f665676..0000000
--- a/client/tests/instance_states_test.rb
+++ /dev/null
@@ -1,66 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.  The
-# ASF licenses this file to you 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 'rubygems'
-require 'require_relative' if RUBY_VERSION =~ /^1\.8/
-
-require_relative './test_helper.rb'
-
-describe "Instance States" do
-
-  it "should allow retrieval of instance-state information" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      instance_states = client.instance_states
-      instance_states.wont_be_nil
-      instance_states.wont_be_empty
-
-      instance_states[0].name.must_equal 'start'
-      instance_states[0].transitions.size.must_equal 1
-      instance_states[0].transitions[0].wont_equal :auto
-
-      instance_states[1].name.must_equal 'pending'
-      instance_states[1].transitions.size.must_equal 1
-      instance_states[1].transitions[0].wont_equal :auto
-
-      instance_states[2].name.must_equal 'running'
-      instance_states[2].transitions.size.must_equal 2
-      includes_transition( instance_states[2].transitions, :reboot, :running ).must_equal true
-      includes_transition( instance_states[2].transitions, :stop, :stopped ).must_equal true
-    end
-  end
-
-  it "should allow retrieval of a single instance-state blob" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      instance_state = client.instance_state( :pending )
-      instance_state.wont_be_nil
-      instance_state.name.must_equal 'pending'
-      instance_state.transitions.size.must_equal 1
-      instance_state.transitions[0].wont_equal :auto
-
-      instance_state = client.instance_state( :running )
-      instance_state.name.must_equal 'running'
-      instance_state.transitions.size.must_equal 2
-      includes_transition( instance_state.transitions, :reboot, :running ).must_equal true
-      includes_transition( instance_state.transitions, :stop, :stopped ).must_equal true
-    end
-  end
-
-  def includes_transition( transitions, action, to )
-    found = transitions.find{|e| e.action.to_s == action.to_s && e.to.to_s == to.to_s }
-    ! found.nil?
-  end
-
-
-end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3d865944/client/tests/instances_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/instances_test.rb b/client/tests/instances_test.rb
deleted file mode 100644
index 0ad990b..0000000
--- a/client/tests/instances_test.rb
+++ /dev/null
@@ -1,203 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.  The
-# ASF licenses this file to you 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 'rubygems'
-require 'require_relative' if RUBY_VERSION =~ /^1\.8/
-
-require_relative './test_helper.rb'
-
-describe "Instances" do
-
-  it "should allow retrieval of all instances" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      instances = client.instances
-      instances.wont_be_empty
-      instances.each do |instance|
-        instance.uri.wont_be_nil
-        instance.uri.must_be_kind_of String
-        instance.owner_id.wont_be_nil
-        instance.owner_id.must_be_kind_of String
-        instance.image.wont_be_nil
-        instance.image.to_s.must_match /DeltaCloud::API::.*::Image/
-        instance.hardware_profile.wont_be_nil
-        instance.hardware_profile.must_be_kind_of DeltaCloud::API::Base::HardwareProfile
-        instance.state.wont_be_nil
-        instance.state.must_be_kind_of String
-        instance.public_addresses.wont_be_nil
-        instance.public_addresses.wont_be_empty
-        instance.public_addresses.must_be_kind_of Array
-        instance.private_addresses.wont_be_nil
-        instance.private_addresses.wont_be_empty
-        instance.private_addresses.must_be_kind_of Array
-      end
-    end
-  end
-
-  it "should allow navigation from instance to image" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      instances = client.instances
-      instances.wont_be_empty
-      instance = instances.first
-      instance.image.wont_be_nil
-      instance.image.description.wont_be_nil
-      instance.image.description.must_be_kind_of String
-    end
-  end
-
-  it "should allow retrieval of a single instance" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      instance = client.instance( "inst0" )
-      instance.wont_be_nil
-      instance.name.wont_be_nil
-      instance.name.must_equal 'Mock Instance With Profile Change'
-      instance.uri.wont_be_nil
-      instance.uri.must_be_kind_of String
-      instance.owner_id.must_equal "mockuser"
-      instance.public_addresses.first.class.must_equal Hash
-      instance.public_addresses.first[:type].must_equal 'hostname'
-      instance.public_addresses.first[:address].must_equal 'img1.inst0.public.com'
-      instance.image.wont_be_nil
-      instance.image.uri.must_equal API_URL + "/images/img1"
-      instance.hardware_profile.wont_be_nil
-      instance.hardware_profile.wont_be_nil
-      instance.hardware_profile.uri.must_equal API_URL + "/hardware_profiles/m1-large"
-      instance.hardware_profile.memory.value.must_equal '10240'
-      instance.hardware_profile.storage.value.must_equal '850'
-      instance.state.must_equal "RUNNING"
-      instance.actions.wont_be_nil
-    end
-  end
-
-  it "should allow creation of new instances with reasonable defaults" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      instance = client.create_instance( 'img1', :name=>'TestInstance', :hardware_profile => 'm1-large' )
-      instance.wont_be_nil
-      instance.uri.must_match %r{#{API_URL}/instances/inst[0-9]+}
-      instance.id.must_match /inst[0-9]+/
-      instance.name.must_equal 'TestInstance'
-      instance.image.id.must_equal 'img1'
-      instance.hardware_profile.id.must_equal 'm1-large'
-      instance.realm.id.must_equal 'us'
-    end
-  end
-
-  it "should allow creation of new instances with specific realm" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      instance = client.create_instance( 'img1', :realm=>'eu', :hardware_profile => 'm1-large' )
-      instance.wont_be_nil
-      instance.uri.must_match %r{#{API_URL}/instances/inst[0-9]+}
-      instance.id.must_match  /inst[0-9]+/
-      instance.image.id.must_equal 'img1'
-      instance.hardware_profile.id.must_equal 'm1-large'
-      instance.realm.id.must_equal 'eu'
-    end
-  end
-
-  it "should allow creation of new instances with specific hardware profile" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      instance = client.create_instance( 'img1',
-                                         :hardware_profile=>'m1-xlarge' )
-      instance.wont_be_nil
-      instance.uri.must_match  %r{#{API_URL}/instances/inst[0-9]+}
-      instance.id.must_match  /inst[0-9]+/
-      instance.image.id.must_equal 'img1'
-      instance.hardware_profile.id.must_equal 'm1-xlarge'
-      instance.realm.id.must_equal 'us'
-    end
-  end
-
-  it "should allow creation of new instances with specific hardware profile overriding memory" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      hwp = { :id => 'm1-xlarge', :memory => 32768 }
-      instance = client.create_instance( 'img1', :hardware_profile=> hwp )
-      instance.wont_be_nil
-      instance.uri.must_match  %r{#{API_URL}/instances/inst[0-9]+}
-      instance.id.must_match  /inst[0-9]+/
-      instance.image.id.must_equal 'img1'
-      instance.hardware_profile.id.must_equal 'm1-xlarge'
-      instance.hardware_profile.memory.value.must_equal'12288'
-      instance.realm.id.must_equal 'us'
-    end
-  end
-
-  it "should allow creation of new instances with specific realm and hardware profile" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      instance = client.create_instance( 'img1', :realm=>'eu',
-                                         :hardware_profile=>'m1-xlarge' )
-      instance.wont_be_nil
-      instance.uri.must_match  %r{#{API_URL}/instances/inst[0-9]+}
-      instance.id.must_match  /inst[0-9]+/
-      instance.image.id.must_equal 'img1'
-      instance.hardware_profile.id.must_equal 'm1-xlarge'
-      instance.realm.id.must_equal 'eu'
-    end
-  end
-
-  it "should allow fetching of instances by id" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      instance = client.instance( 'inst1' )
-      instance.wont_be_nil
-      instance.uri.wont_be_nil
-      instance.uri.must_be_kind_of String
-    end
-  end
-
-  it "should allow fetching of instances by URI" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      instance = client.fetch_instance( API_URL + '/instances/inst1' )
-      instance.wont_be_nil
-      instance.uri.must_equal API_URL + '/instances/inst1'
-      instance.id.must_equal 'inst1'
-    end
-  end
-
-  describe "performing actions on instances" do
-    it "should allow actions that are valid" do
-      DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-        instance = client.instance( 'inst1' )
-        instance.wont_be_nil
-        instance.state.must_equal "RUNNING"
-        instance.uri.must_equal API_URL + '/instances/inst1'
-        instance.id.must_equal 'inst1'
-        instance.stop!
-        instance.state.must_equal "STOPPED"
-        instance.start!
-        instance.state.must_equal "RUNNING"
-      end
-    end
-
-    it "should not allow actions that are invalid" do
-      DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-        instance = client.instance( 'inst1' )
-        instance.wont_be_nil
-        unless instance.state.eql?("RUNNING")
-          instance.start!
-        end
-        instance.state.must_equal "RUNNING"
-        lambda{instance.start!}.must_raise NoMethodError
-      end
-    end
-
-    it "should not throw exception when destroying an instance" do
-      DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-        instance = client.create_instance( 'img1',
-                                           :name=>'TestDestroyInstance',
-                                           :hardware_profile => 'm1-xlarge' )
-        instance.stop!
-        instance.destroy!.must_be_nil
-      end
-    end
-  end
-end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3d865944/client/tests/keys_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/keys_test.rb b/client/tests/keys_test.rb
deleted file mode 100644
index 2610fd4..0000000
--- a/client/tests/keys_test.rb
+++ /dev/null
@@ -1,81 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.  The
-# ASF licenses this file to you 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 'rubygems'
-require 'require_relative' if RUBY_VERSION =~ /^1\.8/
-
-require_relative './test_helper.rb'
-
-def check_key(the_key, key_name = "")
-  the_key.wont_be_nil
-  the_key.id.must_be_kind_of String
-  the_key.id.must_equal key_name
-  the_key.actions.wont_be_nil
-  the_key.actions.size.must_equal 1
-  the_key.actions.first[0].must_equal "destroy"
-  the_key.actions.first[1].must_equal "#{API_URL}/keys/#{key_name}"
-  the_key.fingerprint.wont_be_nil
-  the_key.fingerprint.must_be_kind_of String
-  the_key.pem.wont_be_nil
-  the_key.pem.must_be_kind_of String
-end
-
-def create_key_if_necessary(client, key_name)
-  the_key = client.key(key_name)
-  unless the_key
-    client.create_key()
-  end
-end
-
-
-describe "Keys" do
-  it "should allow retrieval of all keys" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      client.keys.wont_be_empty
-    end
-  end
-end
-
-describe "Operations on Keys" do
-
-  it "should allow successful creation and destroy of a new key" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      new_key = client.create_key({:name => "my_new_key"})
-      check_key(new_key, "my_new_key")
-      the_key = client.key('my_new_key')
-      the_key.destroy!.must_be_nil
-    end
-  end
-
-  it "should allow retrieval of an existing named key" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      key_name = "test-key"
-      create_key_if_necessary(client, key_name)
-      the_key = client.key(key_name)
-      check_key(the_key, key_name)
-    end
-  end
-
-  it "should raise error if you create a key with the same name as an existing key" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      name = "test-key"
-      create_key_if_necessary(client, name)
-      lambda{
-              client.create_key({:name => name})
-            }.must_raise DeltaCloud::HTTPError::Forbidden
-    end
-  end
-
-end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3d865944/client/tests/methods/address_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/methods/address_test.rb b/client/tests/methods/address_test.rb
new file mode 100644
index 0000000..90e4478
--- /dev/null
+++ b/client/tests/methods/address_test.rb
@@ -0,0 +1,64 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you 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_relative '../test_helper'
+
+describe Deltacloud::Client::Methods::Address do
+
+  before do
+    VCR.insert_cassette(__name__)
+    @client = new_client
+  end
+
+  after do
+    VCR.eject_cassette
+  end
+
+  it 'supports #addresses' do
+    @client.must_respond_to :addresses
+    @client.addresses.must_be_kind_of Array
+    @client.addresses.each { |r| r.must_be_instance_of Deltacloud::Client::Address }
+  end
+
+  it 'supports filtering #addresses by :id param' do
+    result = @client.addresses(:id => '192.168.0.1')
+    result.must_be_kind_of Array
+    result.size.must_equal 1
+    result.first.must_be_instance_of Deltacloud::Client::Address
+    result = @client.addresses(:id => 'unknown')
+    result.must_be_kind_of Array
+    result.size.must_equal 0
+  end
+
+  it 'support #address' do
+    @client.must_respond_to :address
+    result = @client.address('192.168.0.1')
+    result.must_be_instance_of Deltacloud::Client::Address
+    lambda { @client.address(nil) }.must_raise Deltacloud::Client::NotFound
+    lambda { @client.address('foo') }.must_raise Deltacloud::Client::NotFound
+  end
+
+  it 'support #create_address' do
+    @client.must_respond_to :create_address
+    result = @client.create_address
+    result.must_be_instance_of Deltacloud::Client::Address
+    result.ip.wont_be_empty
+    result.instance_id.must_be_nil
+    @client.must_respond_to :destroy_address
+    @client.destroy_address(result._id).must_equal true
+    lambda { @client.address(result._id) }.must_raise Deltacloud::Client::NotFound
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3d865944/client/tests/methods/api_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/methods/api_test.rb b/client/tests/methods/api_test.rb
new file mode 100644
index 0000000..25e167e
--- /dev/null
+++ b/client/tests/methods/api_test.rb
@@ -0,0 +1,97 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you 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_relative '../test_helper'
+
+describe Deltacloud::Client::Methods::Api do
+
+  before do
+    VCR.insert_cassette(__name__)
+    @client = new_client
+  end
+
+  after do
+    VCR.eject_cassette
+  end
+
+  it 'supports #path' do
+    @client.must_respond_to :path
+    @client.path.must_be_kind_of String
+    @client.path.must_equal '/api'
+  end
+
+  it 'supports #api_uri' do
+    @client.must_respond_to :api_uri
+    @client.api_uri('/sample').must_be_kind_of URI::Generic
+    @client.api_uri('/sample').to_s.must_equal '/api/sample'
+  end
+
+  it 'supports #version' do
+    @client.must_respond_to :version
+    @client.version.must_equal '1.1.1'
+  end
+
+  it 'supports #current_driver' do
+    @client.must_respond_to :current_driver
+    @client.current_driver.must_equal 'mock'
+  end
+
+  it 'supports #current_provider' do
+    @client.must_respond_to :current_provider
+    @client.current_provider.must_be_nil
+    @client.use(:ec2, 'foo', 'bar', 'eu-west-1').current_provider.must_equal 'eu-west-1'
+  end
+
+  it 'supports #supported_collections' do
+    @client.must_respond_to :supported_collections
+    @client.supported_collections.must_be_kind_of Array
+    @client.supported_collections.wont_be_empty
+    @client.supported_collections.must_include 'realms'
+  end
+
+  it 'supports #support?' do
+    @client.must_respond_to :"support?"
+    @client.support?('realms').must_equal true
+    @client.support?(:realms).must_equal true
+    @client.support?('foo').must_equal false
+  end
+
+  it 'supports #must_support!' do
+    @client.must_respond_to :"must_support!"
+    @client.must_support!(:realms).must_be_nil
+    @client.must_support!('realms').must_be_nil
+    lambda { @client.must_support!(:foo) }.must_raise @client.error(:not_supported)
+  end
+
+  it 'supports #features' do
+    @client.must_respond_to :features
+    @client.features.must_be_kind_of Hash
+    @client.features['instances'].wont_be_nil
+    @client.features['instances'].must_be_kind_of Array
+    @client.features['instances'].wont_be_empty
+    @client.features['instances'].must_include 'user_name'
+    @client.features['instances'].wont_include nil
+  end
+
+  it 'supports #feature?' do
+    @client.must_respond_to :"feature?"
+    @client.feature?(:instances, 'user_name').must_equal true
+    @client.feature?('instances', :user_name).must_equal true
+    @client.feature?('instances', :foo).must_equal false
+    @client.feature?(:foo, :foo).must_equal false
+    @client.feature?(nil, nil).must_equal false
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3d865944/client/tests/methods/backward_compatibility_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/methods/backward_compatibility_test.rb b/client/tests/methods/backward_compatibility_test.rb
new file mode 100644
index 0000000..6e71c3c
--- /dev/null
+++ b/client/tests/methods/backward_compatibility_test.rb
@@ -0,0 +1,87 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you 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_relative '../test_helper'
+
+describe Deltacloud::Client::Methods::BackwardCompatibility do
+
+  before do
+    VCR.insert_cassette(__name__)
+    @client = new_client
+  end
+
+  after do
+    VCR.eject_cassette
+  end
+
+  it 'supports #api_host' do
+    @client.must_respond_to :api_host
+    @client.api_host.must_equal 'localhost'
+  end
+
+  it 'supports #api_port' do
+    @client.must_respond_to :api_port
+    @client.api_port.must_equal 3001
+  end
+
+  it 'supports #connect' do
+    @client.must_respond_to :connect
+    @client.connect do |new_client|
+      new_client.must_be_instance_of Deltacloud::Client::Connection
+    end
+  end
+
+  it 'supports #with_config' do
+    @client.must_respond_to :with_config
+    @client.with_config(:driver => :ec2, :username => 'f', :password => 'b') do |c|
+      c.must_be_instance_of Deltacloud::Client::Connection
+      c.current_driver.must_equal 'ec2'
+      c.request_driver.must_equal :ec2
+    end
+  end
+
+  it 'supports #use_driver' do
+    @client.must_respond_to :use_driver
+    @client.use_driver(:ec2, :username => 'f', :password => 'b') do |c|
+      c.must_be_instance_of Deltacloud::Client::Connection
+      c.current_driver.must_equal 'ec2'
+      c.request_driver.must_equal :ec2
+    end
+  end
+
+  it 'supports #discovered?' do
+    @client.must_respond_to :"discovered?"
+    @client.discovered?.must_equal true
+  end
+
+  it 'supports #valid_credentials? on class' do
+    Deltacloud::Client.must_respond_to :"valid_credentials?"
+    r = Deltacloud::Client.valid_credentials? DELTACLOUD_USER,
+      DELTACLOUD_PASSWORD, DELTACLOUD_URL
+    r.must_equal true
+    r = Deltacloud::Client.valid_credentials? 'foo',
+      DELTACLOUD_PASSWORD, DELTACLOUD_URL
+    r.must_equal false
+    r = Deltacloud::Client.valid_credentials? 'foo',
+      'bar', DELTACLOUD_URL
+    r.must_equal false
+    lambda {
+      Deltacloud::Client.valid_credentials? 'foo',
+        'bar', 'http://unknown.local'
+    }.must_raise Faraday::Error::ConnectionFailed
+  end
+
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3d865944/client/tests/methods/blob_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/methods/blob_test.rb b/client/tests/methods/blob_test.rb
new file mode 100644
index 0000000..7cb55be
--- /dev/null
+++ b/client/tests/methods/blob_test.rb
@@ -0,0 +1,64 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you 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_relative '../test_helper'
+
+describe Deltacloud::Client::Methods::Blob do
+
+  before do
+    VCR.insert_cassette(__name__)
+    @client = new_client
+  end
+
+  after do
+    VCR.eject_cassette
+  end
+
+  it 'supports #blobs' do
+    @client.must_respond_to :blobs
+    @client.blobs('bucket1').must_be_kind_of Array
+    @client.blobs('bucket1').each { |r| r.must_be_instance_of Deltacloud::Client::Blob }
+  end
+
+  it 'support #blob' do
+    @client.must_respond_to :blob
+    result = @client.blob('bucket1', 'blob1')
+    result.must_be_instance_of Deltacloud::Client::Blob
+    lambda { @client.blob('bucket1', 'foo') }.must_raise Deltacloud::Client::NotFound
+  end
+
+  it 'support #create_blob and #destroy_blob' do
+    @client.must_respond_to :create_blob
+    result = @client.create_blob('bucket1', 'fooblob123', 'content_of_blob')
+    result.must_be_instance_of Deltacloud::Client::Blob
+    result.bucket_id.must_equal 'bucket1'
+    result._id.must_equal 'fooblob123'
+    result.content_length.must_equal '15'
+    result.content_type.must_equal 'text/plain'
+    @client.must_respond_to :destroy_blob
+    @client.destroy_blob('bucket1', result._id).must_equal true
+  end
+
+  it 'support #create_blob and #destroy_blob with meta_params' do
+    @client.must_respond_to :create_blob
+    result = @client.create_blob('bucket1', 'fooblob123', 'content', :user_metadata => { :key => :value })
+    result.must_be_instance_of Deltacloud::Client::Blob
+    result.user_metadata.must_be_kind_of Hash
+    result.user_metadata['key'].must_equal 'value'
+    @client.must_respond_to :destroy_blob
+    @client.destroy_blob('bucket1', result._id).must_equal true
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3d865944/client/tests/methods/bucket_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/methods/bucket_test.rb b/client/tests/methods/bucket_test.rb
new file mode 100644
index 0000000..6b6736d
--- /dev/null
+++ b/client/tests/methods/bucket_test.rb
@@ -0,0 +1,62 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you 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_relative '../test_helper'
+
+describe Deltacloud::Client::Methods::Bucket do
+
+  before do
+    VCR.insert_cassette(__name__)
+    @client = new_client
+  end
+
+  after do
+    VCR.eject_cassette
+  end
+
+  it 'supports #buckets' do
+    @client.must_respond_to :buckets
+    @client.buckets.must_be_kind_of Array
+    @client.buckets.each { |r| r.must_be_instance_of Deltacloud::Client::Bucket }
+  end
+
+  it 'supports filtering #buckets by :id param' do
+    result = @client.buckets(:id => 'bucket1')
+    result.must_be_kind_of Array
+    result.size.must_equal 1
+    result.first.must_be_instance_of Deltacloud::Client::Bucket
+    result = @client.buckets(:id => 'unknown')
+    result.must_be_kind_of Array
+    result.size.must_equal 0
+  end
+
+  it 'support #bucket' do
+    @client.must_respond_to :bucket
+    result = @client.bucket('bucket1')
+    result.must_be_instance_of Deltacloud::Client::Bucket
+    lambda { @client.bucket(nil) }.must_raise Deltacloud::Client::NotFound
+    lambda { @client.bucket('foo') }.must_raise Deltacloud::Client::NotFound
+  end
+
+  it 'support #create_bucket and #destroy_bucket' do
+    @client.must_respond_to :create_bucket
+    b = @client.create_bucket('foo123')
+    b.must_be_instance_of Deltacloud::Client::Bucket
+    b.name.must_equal 'foo123'
+    @client.destroy_bucket(b._id)
+    lambda { @client.bucket(b._id) }.must_raise Deltacloud::Client::NotFound
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3d865944/client/tests/methods/driver_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/methods/driver_test.rb b/client/tests/methods/driver_test.rb
new file mode 100644
index 0000000..3872c85
--- /dev/null
+++ b/client/tests/methods/driver_test.rb
@@ -0,0 +1,48 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you 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_relative '../test_helper'
+
+describe Deltacloud::Client::Methods::Driver do
+
+  before do
+    VCR.insert_cassette(__name__)
+    @client = new_client
+  end
+
+  after do
+    VCR.eject_cassette
+  end
+
+  it 'supports #drivers' do
+    @client.must_respond_to :drivers
+    @client.drivers.must_be_kind_of Array
+    @client.drivers.each { |r| r.must_be_instance_of Deltacloud::Client::Driver }
+  end
+
+  it 'supports #driver' do
+    @client.must_respond_to :driver
+    result = @client.driver('ec2')
+    result.must_be_instance_of Deltacloud::Client::Driver
+    lambda { @client.driver(nil) }.must_raise Deltacloud::Client::NotFound
+    lambda { @client.driver('foo') }.must_raise Deltacloud::Client::NotFound
+  end
+
+  it 'supports #providers' do
+    @client.must_respond_to :providers
+    @client.providers.must_be_empty
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3d865944/client/tests/methods/firewall_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/methods/firewall_test.rb b/client/tests/methods/firewall_test.rb
new file mode 100644
index 0000000..967b535
--- /dev/null
+++ b/client/tests/methods/firewall_test.rb
@@ -0,0 +1,84 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you 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_relative '../test_helper'
+
+describe Deltacloud::Client::Methods::Firewall do
+
+  def new_client
+    Deltacloud::Client(DELTACLOUD_URL, 'AKIAJYOQYLLOIWN5LQ3A', 'Ra2ViYaYgocAJqPAQHxMVU/l2sGGU2pifmWT4q3H', :driver => :ec2 )
+  end
+
+  before do
+    VCR.insert_cassette(__name__)
+    @client = new_client
+  end
+
+  after do
+    VCR.eject_cassette
+  end
+
+  it 'supports #firewalls' do
+    @client.must_respond_to :firewalls
+    begin
+      @client.firewalls.must_be_kind_of Array
+    rescue Deltacloud::Client::AuthenticationError
+      skip
+    end
+    @client.firewalls.each { |r| r.must_be_instance_of Deltacloud::Client::Firewall }
+  end
+
+  it 'supports filtering #firewalls by :id param' do
+    begin
+      result = @client.firewalls(:id => 'mfojtik')
+    rescue Deltacloud::Client::AuthenticationError
+      skip
+    end
+    result.must_be_kind_of Array
+    result.size.must_equal 1
+    result.first.must_be_instance_of Deltacloud::Client::Firewall
+  end
+
+  it 'support #firewall' do
+    @client.must_respond_to :firewall
+    begin
+      result = @client.firewall('mfojtik')
+    rescue
+      skip
+    end
+    result.must_be_instance_of Deltacloud::Client::Firewall
+    lambda { @client.firewall(nil) }.must_raise Deltacloud::Client::NotFound
+    lambda { @client.firewall('foo') }.must_raise Deltacloud::Client::NotFound
+  end
+
+  it 'support #create_firewall and #destroy_firewall' do
+    @client.must_respond_to :create_firewall
+    @client.must_respond_to :destroy_firewall
+    begin
+      result = @client.create_firewall('foofirewall', :description => 'testing firewalls')
+      result.must_be_instance_of Deltacloud::Client::Firewall
+      result.name.must_equal 'foofirewall'
+      @client.destroy_firewall(result._id).must_equal true
+      lambda {
+        @client.create_firewall('foofirewall')
+      }.must_raise Deltacloud::Client::ClientFailure
+    rescue
+      skip
+    end
+  end
+
+
+  # FIXME: TBD, not supported by mock driver yet.
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3d865944/client/tests/methods/hardware_profile_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/methods/hardware_profile_test.rb b/client/tests/methods/hardware_profile_test.rb
new file mode 100644
index 0000000..1e49c46
--- /dev/null
+++ b/client/tests/methods/hardware_profile_test.rb
@@ -0,0 +1,53 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you 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_relative '../test_helper'
+
+describe Deltacloud::Client::Methods::HardwareProfile do
+
+  before do
+    VCR.insert_cassette(__name__)
+    @client = new_client
+  end
+
+  after do
+    VCR.eject_cassette
+  end
+
+  it 'supports #hardware_profiles' do
+    @client.must_respond_to :hardware_profiles
+    @client.hardware_profiles.must_be_kind_of Array
+    @client.hardware_profiles.each { |r| r.must_be_instance_of Deltacloud::Client::HardwareProfile }
+  end
+
+  it 'supports filtering #hardware_profiles by :id param' do
+    result = @client.hardware_profiles(:id => 'm1-small')
+    result.must_be_kind_of Array
+    result.size.must_equal 1
+    result.first.must_be_instance_of Deltacloud::Client::HardwareProfile
+    result = @client.hardware_profiles(:id => 'unknown')
+    result.must_be_kind_of Array
+    result.size.must_equal 0
+  end
+
+  it 'support #hardware_profile' do
+    @client.must_respond_to :hardware_profile
+    result = @client.hardware_profile('m1-small')
+    result.must_be_instance_of Deltacloud::Client::HardwareProfile
+    lambda { @client.hardware_profile(nil) }.must_raise Deltacloud::Client::NotFound
+    lambda { @client.hardware_profile('foo') }.must_raise Deltacloud::Client::NotFound
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3d865944/client/tests/methods/image_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/methods/image_test.rb b/client/tests/methods/image_test.rb
new file mode 100644
index 0000000..6d505e1
--- /dev/null
+++ b/client/tests/methods/image_test.rb
@@ -0,0 +1,64 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you 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_relative '../test_helper'
+
+describe Deltacloud::Client::Methods::Image do
+
+  before do
+    VCR.insert_cassette(__name__)
+    @client = new_client
+  end
+
+  after do
+    VCR.eject_cassette
+  end
+
+  it 'supports #images' do
+    @client.must_respond_to :images
+    @client.images.must_be_kind_of Array
+    @client.images.each { |r| r.must_be_instance_of Deltacloud::Client::Image }
+  end
+
+  it 'supports filtering #images by :id param' do
+    result = @client.images(:id => 'img1')
+    result.must_be_kind_of Array
+    result.size.must_equal 1
+    result.first.must_be_instance_of Deltacloud::Client::Image
+    result = @client.images(:id => 'unknown')
+    result.must_be_kind_of Array
+    result.size.must_equal 0
+  end
+
+  it 'support #image' do
+    @client.must_respond_to :image
+    result = @client.image('img1')
+    result.must_be_instance_of Deltacloud::Client::Image
+    lambda { @client.image(nil) }.must_raise Deltacloud::Client::NotFound
+    lambda { @client.image('foo') }.must_raise Deltacloud::Client::NotFound
+  end
+
+  it 'support #create_image and #destroy_image' do
+    @client.must_respond_to :create_image
+    img = @client.create_image('inst1', :name => 'test')
+    img.must_be_instance_of Deltacloud::Client::Image
+    img.name.must_equal 'test'
+    @client.destroy_image(img._id)
+    lambda {
+      @client.create_image(nil, :name => 'test')
+    }.must_raise Deltacloud::Client::ServerError
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3d865944/client/tests/methods/instance_state_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/methods/instance_state_test.rb b/client/tests/methods/instance_state_test.rb
new file mode 100644
index 0000000..bad6ae5
--- /dev/null
+++ b/client/tests/methods/instance_state_test.rb
@@ -0,0 +1,43 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you 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_relative '../test_helper'
+
+describe Deltacloud::Client::Methods::InstanceState do
+
+  before do
+    VCR.insert_cassette(__name__)
+    @client = new_client
+  end
+
+  after do
+    VCR.eject_cassette
+  end
+
+  it 'supports #instance_states' do
+    @client.must_respond_to :instance_states
+    @client.instance_states.must_be_kind_of Array
+    @client.instance_states.each { |r| r.must_be_instance_of Deltacloud::Client::InstanceState::State }
+  end
+
+  it 'support #instance_state' do
+    @client.must_respond_to :instance_state
+    result = @client.instance_state('start')
+    result.must_be_instance_of Deltacloud::Client::InstanceState::State
+    @client.instance_state(nil).must_be_nil
+    @client.instance_state('foo').must_be_nil
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3d865944/client/tests/methods/instance_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/methods/instance_test.rb b/client/tests/methods/instance_test.rb
new file mode 100644
index 0000000..47b3934
--- /dev/null
+++ b/client/tests/methods/instance_test.rb
@@ -0,0 +1,120 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you 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_relative '../test_helper'
+
+describe Deltacloud::Client::Methods::Instance do
+
+  before do
+    VCR.insert_cassette(__name__)
+    @client = new_client
+    @created_instances = []
+  end
+
+  after do
+    VCR.eject_cassette
+    VCR.use_cassette('instances_cleanup') do
+      cleanup_instances(@created_instances)
+    end
+  end
+
+  it 'supports #instances' do
+    @client.must_respond_to :instances
+    @client.instances.must_be_kind_of Array
+    @client.instances.each { |r| r.must_be_instance_of Deltacloud::Client::Instance }
+  end
+
+  it 'supports filtering #instances by :id param' do
+    result = @client.instances(:id => 'inst1')
+    result.must_be_kind_of Array
+    result.size.must_equal 1
+    result.first.must_be_instance_of Deltacloud::Client::Instance
+    result = @client.instances(:id => 'unknown')
+    result.must_be_kind_of Array
+    result.size.must_equal 0
+  end
+
+  it 'support #instance' do
+    @client.must_respond_to :instance
+    result = @client.instance('inst1')
+    result.must_be_instance_of Deltacloud::Client::Instance
+    lambda { @client.instance(nil) }.must_raise Deltacloud::Client::NotFound
+    lambda { @client.instance('foo') }.must_raise Deltacloud::Client::NotFound
+  end
+
+  it 'support #create_instance' do
+    @client.must_respond_to :create_instance
+    inst = @client.create_instance('img1')
+    inst.must_be_instance_of Deltacloud::Client::Instance
+    inst.image_id.must_equal 'img1'
+    @created_instances << inst
+  end
+
+  it 'support #create_instance with hwp_id' do
+    @client.must_respond_to :create_instance
+    inst = @client.create_instance('img1', :hwp_id => 'm1-large')
+    inst.must_be_instance_of Deltacloud::Client::Instance
+    inst.image_id.must_equal 'img1'
+    inst.hardware_profile_id.must_equal 'm1-large'
+    @created_instances << inst
+  end
+
+  it 'support #create_instance with realm_id' do
+    @client.must_respond_to :create_instance
+    inst = @client.create_instance('img1', :realm_id => 'eu')
+    inst.must_be_instance_of Deltacloud::Client::Instance
+    inst.realm_id.must_equal 'eu'
+    @created_instances << inst
+  end
+
+  it 'support #create_instance with name' do
+    @client.must_respond_to :create_instance
+    inst = @client.create_instance('img1', :realm_id => 'eu', :name => 'test_instance')
+    inst.must_be_instance_of Deltacloud::Client::Instance
+    inst.name.must_equal 'test_instance'
+    inst.realm_id.must_equal 'eu'
+    @created_instances << inst
+  end
+
+  it 'support #stop_instance' do
+    @client.must_respond_to :stop_instance
+    inst = @client.create_instance('img1')
+    inst.must_be_instance_of Deltacloud::Client::Instance
+    inst = @client.stop_instance(inst._id)
+    inst.state.must_equal 'STOPPED'
+    @created_instances << inst
+  end
+
+  it 'support #start_instance' do
+    @client.must_respond_to :start_instance
+    inst = @client.create_instance('img1')
+    inst.must_be_instance_of Deltacloud::Client::Instance
+    inst = @client.stop_instance(inst._id)
+    inst.state.must_equal 'STOPPED'
+    inst = inst.start_instance(inst._id)
+    inst.state.must_equal 'RUNNING'
+    @created_instances << inst
+  end
+
+  it 'support #reboot_instance' do
+    @client.must_respond_to :reboot_instance
+    inst = @client.create_instance('img1')
+    inst.must_be_instance_of Deltacloud::Client::Instance
+    inst = @client.reboot_instance(inst._id)
+    inst.state.must_equal 'RUNNING'
+    @created_instances << inst
+  end
+
+end


Mime
View raw message