deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [1/2] git commit: CIMI - tests add creation of volume with config by value
Date Tue, 11 Dec 2012 14:31:50 GMT
Updated Branches:
  refs/heads/master a6626df52 -> b0ed6a998


CIMI - tests add creation of volume with config by value


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

Branch: refs/heads/master
Commit: b0ed6a9982a6ebca5fe727f26b6aa97ec0cf29eb
Parents: ab1f43c
Author: marios <marios@redhat.com>
Authored: Wed Dec 5 15:26:56 2012 +0200
Committer: marios <marios@redhat.com>
Committed: Tue Dec 11 16:30:45 2012 +0200

----------------------------------------------------------------------
 server/lib/cimi/models/volume.rb |    3 +-
 tests/cimi/part4_test.rb         |   39 +++++++++++++++++++++++++++++++++
 tests/cimi/test_helper.rb        |    7 ++++++
 3 files changed, 47 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/b0ed6a99/server/lib/cimi/models/volume.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/volume.rb b/server/lib/cimi/models/volume.rb
index a2904ce..afef16f 100644
--- a/server/lib/cimi/models/volume.rb
+++ b/server/lib/cimi/models/volume.rb
@@ -69,10 +69,9 @@ class CIMI::Model::Volume < CIMI::Model::Base
     end
   end
 
-
   def self.delete!(id, context)
     context.driver.destroy_storage_volume(context.credentials, {:id=>id} )
-    delete_attributes_for(Volume.new(:id => id))
+    context.delete_attributes_for(StorageVolume.new(:id => id))
   end
 
   def self.find_to_attach_from_json(json_in, context)

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/b0ed6a99/tests/cimi/part4_test.rb
----------------------------------------------------------------------
diff --git a/tests/cimi/part4_test.rb b/tests/cimi/part4_test.rb
index 5727956..04dd7f3 100644
--- a/tests/cimi/part4_test.rb
+++ b/tests/cimi/part4_test.rb
@@ -81,6 +81,45 @@ class AddVolumeToMachine < CIMI::Test::Spec
     get resp.location
   end
 
+  it "should allow creation of Volume with Config by value in XML" do
+    volume_add_uri = discover_uri_for("add", "volumes")
+    res = post(volume_add_uri,
+      "<VolumeCreate>" +
+        "<name>cimi_volume_by_value_xml</name>" +
+        "<description>volume for testing</description>" +
+        "<volumeTemplate>" +
+          "<volumeConfig>" +
+            "<type>http://schemas.dmtf.org/cimi/1/mapped</type>"+
+            "<capacity> 1024 </capacity>" +
+          "</volumeConfig>" +
+        "</volumeTemplate>" +
+      "</VolumeCreate>",
+         :accept => :json, :content_type => :xml)
+    res.code.must_equal 201
+    #cleanup
+    delete_uri = discover_uri_for("delete", "volumes", res.json["operations"])
+    res= delete(delete_uri)
+    res.code.must_equal 200
+  end
+
+  it "should allow creation of Volume with Config by value in JSON" do
+    volume_add_uri = discover_uri_for("add", "volumes")
+    res = post(volume_add_uri,
+      '{"name": "marios_new_volume_json", "description": "a new volume",' +
+        ' "volumeTemplate":'+
+            '{"volumeConfig": '+
+              '{"type":"http://schemas.dmtf.org/cimi/1/mapped", "capacity": 1024 }}}',
+       :accept => :json, :content_type => :json)
+    res.code.must_equal 201
+    #cleanup
+    delete_uri = discover_uri_for("delete", "volumes", res.json["operations"])
+    res= delete(delete_uri)
+    res.code.must_equal 200
+  end
+
+
+  #this test is not strictly part of the cimi plugfest scenario
+  #added for DTACLOUD-385
   it "should add resource machine resource for cleanup", :only => :json do
     @@created_resources[:machines] << machine.location
   end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/b0ed6a99/tests/cimi/test_helper.rb
----------------------------------------------------------------------
diff --git a/tests/cimi/test_helper.rb b/tests/cimi/test_helper.rb
index 3605228..025a705 100644
--- a/tests/cimi/test_helper.rb
+++ b/tests/cimi/test_helper.rb
@@ -148,6 +148,13 @@ module CIMI::Test::Methods
       resp
     end
 
+    def delete(path, params={})
+      log_request(:delete, path, :params=>params)
+      resp  = RestClient.delete absolute_url(path), headers(params)
+      log_response(:delete, path, resp)
+      resp
+    end
+
     # Find the model class that can process the body of the HTTP response
     # +resp+
     def model_class(resp)


Mime
View raw message