deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject [2/14] git commit: CIMI tests: streamline part2
Date Tue, 11 Dec 2012 03:48:24 GMT
CIMI tests: streamline part2

Some servers do not return a body for create requests (which is legal)


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

Branch: refs/heads/master
Commit: 402fd685d3b15f360fcaa169af3de0ffed3b4433
Parents: f715fa6
Author: David Lutterkort <lutter@redhat.com>
Authored: Wed Dec 5 16:09:03 2012 -0800
Committer: David Lutterkort <lutter@redhat.com>
Committed: Mon Dec 10 17:08:49 2012 -0800

----------------------------------------------------------------------
 tests/cimi/part2_test.rb |   33 ++++++++++++++-------------------
 1 files changed, 14 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/402fd685/tests/cimi/part2_test.rb
----------------------------------------------------------------------
diff --git a/tests/cimi/part2_test.rb b/tests/cimi/part2_test.rb
index a70c6ed..1be48f0 100644
--- a/tests/cimi/part2_test.rb
+++ b/tests/cimi/part2_test.rb
@@ -51,14 +51,15 @@ end
 
   # 2.4:  Create a new CredentialResource
   log.info("Create a new CredentialResource: credential_resources is not a supported collection.")
-  # 2.5: Create a new Machine
-  model :machine do |fmt|
+
+  it "allows creation of a new machine (step 2.5)", :only => :json do
     cep_json = cep(:accept => :json)
     #discover the 'addURI' for creating Machine
     add_uri = discover_uri_for("add", "machines")
-    post(add_uri,
+
+    resp = post(add_uri,
       "<MachineCreate xmlns=\"#{CIMI::Test::CIMI_NAMESPACE}\">" +
-        "<name>cimi_machine_" + fmt.to_s() + "</name>" +
+        "<name>cimi_machine_" + format.to_s + "</name>" +
         "<machineTemplate>" +
           "<machineConfig " +
             "href=\"" + get_a(cep_json, "machineConfig")+ "\"/>" +
@@ -66,21 +67,15 @@ end
             "href=\"" + get_a(cep_json, "machineImage") + "\"/>" +
         "</machineTemplate>" +
       "</MachineCreate>", :content_type => :xml)
-  end
-
-  it "should add resource for cleanup" do
-    @@created_resources[:machines] << machine.id
-  end
 
-  it "should have a name" do
-    machine.name.wont_be_empty
-    log.info("machine name: " + machine.name)
-  end
-
-  it "should produce a valid create response" do
-    machine
-    last_response.code.must_be_one_of [201, 202]
-    last_response.headers[:location].must_be_uri
+    resp.headers[:location].must_be_uri
+    resp.code.must_be_one_of [201, 202]
+    if resp.code == 201
+      machine = fetch(resp.headers[:location])
+      machine.name.wont_be_empty
+    else
+      machine = CIMI::Model::Machinemachine.new(:id => resp.headers[:location])
+    end
+    @@created_resources[:machines] << machine
   end
-
 end


Mime
View raw message