deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@redhat.com
Subject [PATCH 06/13] CIMI tests: check creations against what the spec allows
Date Thu, 06 Dec 2012 02:42:50 GMT
From: David Lutterkort <lutter@redhat.com>

The spec allows returning status 201 or 202; Location header must be set
---
 tests/cimi/part2_test.rb |    5 +++--
 tests/cimi/part3_test.rb |    5 +++--
 tests/cimi/part4_test.rb |    5 +++--
 tests/helpers/common.rb  |    1 +
 4 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/tests/cimi/part2_test.rb b/tests/cimi/part2_test.rb
index cc6041d..a70c6ed 100644
--- a/tests/cimi/part2_test.rb
+++ b/tests/cimi/part2_test.rb
@@ -77,9 +77,10 @@ end
     log.info("machine name: " + machine.name)
   end
 
-  it "should have a response code equal to 201" do
+  it "should produce a valid create response" do
     machine
-    last_response.code.must_equal 201
+    last_response.code.must_be_one_of [201, 202]
+    last_response.headers[:location].must_be_uri
   end
 
 end
diff --git a/tests/cimi/part3_test.rb b/tests/cimi/part3_test.rb
index 9703618..6da7cf8 100644
--- a/tests/cimi/part3_test.rb
+++ b/tests/cimi/part3_test.rb
@@ -110,9 +110,10 @@ class CreateNewMachineFromMachineTemplate < CIMI::Test::Spec
     log.info("machine name: " + machine.name)
   end
 
-  it "should have a response code equal to 201" do
+  it "should produce a valid create response" do
     machine
-    last_response.code.must_equal 201
+    last_response.code.must_be_one_of [201, 202]
+    last_response.headers[:location].must_be_uri
   end
 
 end
diff --git a/tests/cimi/part4_test.rb b/tests/cimi/part4_test.rb
index 72f22af..c6848c2 100644
--- a/tests/cimi/part4_test.rb
+++ b/tests/cimi/part4_test.rb
@@ -93,9 +93,10 @@ class AddVolumeToMachine < CIMI::Test::Spec
     log.info("volume name: " + volume.name)
   end
 
-  it "should have a response code equal to 201 for creating a volume" do
+  it "should produce a valid create response" do
     volume
-    last_response.code.must_equal 201
+    last_response.code.must_be_one_of [201, 202]
+    last_response.headers[:location].must_be_uri
   end
 
   it "should have the correct resourceURI", :only => :json do
diff --git a/tests/helpers/common.rb b/tests/helpers/common.rb
index fd627a2..00266e5 100644
--- a/tests/helpers/common.rb
+++ b/tests/helpers/common.rb
@@ -84,3 +84,4 @@ module MiniTest::Assertions
 end
 
 MiniTest::Expectations::infect_an_assertion :assert_uri, :must_be_uri, :unary
+MiniTest::Expectations::infect_an_assertion :assert_includes, :must_be_one_of
-- 
1.7.7.6


Mime
View raw message