deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [22/31] git commit: * deltacloud/test_setup.rb: change post/delete/options the same way as get
Date Wed, 25 Jul 2012 13:56:38 GMT
* deltacloud/test_setup.rb: change post/delete/options the same way as get


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

Branch: refs/heads/master
Commit: 6db26b4e94fa253d8a5b92f44fe6a11a05e5fed3
Parents: f76ebc2
Author: David Lutterkort <lutter@redhat.com>
Authored: Fri Jul 20 17:35:23 2012 -0700
Committer: marios <marios@redhat.com>
Committed: Tue Jul 24 12:01:36 2012 +0300

----------------------------------------------------------------------
 tests/deltacloud/buckets_test.rb |    4 ++--
 tests/deltacloud/test_setup.rb   |   30 ++++++++++++------------------
 2 files changed, 14 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/6db26b4e/tests/deltacloud/buckets_test.rb
----------------------------------------------------------------------
diff --git a/tests/deltacloud/buckets_test.rb b/tests/deltacloud/buckets_test.rb
index 58d6d6c..8bae4fd 100644
--- a/tests/deltacloud/buckets_test.rb
+++ b/tests/deltacloud/buckets_test.rb
@@ -50,7 +50,7 @@ describe 'Deltacloud API buckets collection' do
   it 'should be possible to create bucket with POST /api/buckets and delete it with DELETE
/api/buckets/:id' do
     bucket_name = random_name
     #create bucket
-    res = post({:name=>bucket_name}, BUCKETS, {}, true)
+    res = post(BUCKETS, :name=>bucket_name)
     #check response
     res.code.must_equal 201
     xml_res = xml_response(res)
@@ -61,7 +61,7 @@ describe 'Deltacloud API buckets collection' do
     res = get(BUCKETS+"/"+bucket_name)
     res.code.must_equal 200
     #DELETE bucket
-    res = delete({}, BUCKETS+"/"+bucket_name)
+    res = delete(BUCKETS+"/"+bucket_name)
     res.code.must_equal 204
   end
 

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/6db26b4e/tests/deltacloud/test_setup.rb
----------------------------------------------------------------------
diff --git a/tests/deltacloud/test_setup.rb b/tests/deltacloud/test_setup.rb
index b74b785..ce1975c 100644
--- a/tests/deltacloud/test_setup.rb
+++ b/tests/deltacloud/test_setup.rb
@@ -65,25 +65,19 @@ def get(path, params={})
   RestClient.get url, headers
 end
 
-def post(post_body = "", path= "", params={}, authenticate = false)
-  if authenticate
-    params.merge!({:Authorization=>BASIC_AUTH})
-  end
-  RestClient.post API_URL+path, post_body, params
+def post(path, post_body, params={})
+  url, headers = process_url_params(path, params)
+  RestClient.post url, post_body, headers
 end
 
-def delete(params={}, path = "", authenticate = true)
-  if authenticate
-    params.merge!({:Authorization=>BASIC_AUTH})
-  end
-  RestClient.delete API_URL+path, params
+def delete(path, params={})
+  url, headers = process_url_params(path, params)
+  RestClient.delete url, headers
 end
 
-def options(params={}, path="", authenticate = false)
-  if authenticate
-    params.merge!({:Authorization=>BASIC_AUTH})
-  end
-  RestClient.options API_URL+path, params
+def options(path, params={})
+  url, headers = process_url_params(path, params)
+  RestClient.options url, headers
 end
 
 # Should be private
@@ -143,7 +137,7 @@ def create_a_bucket_and_blob
   blob_name = random_name
   #create bucket:
   #  res = RestClient.post "#{API_URL}/buckets", {:name=>bucket_name}, {:Authorization=>BASIC_AUTH}
-  res = post({:name=>bucket_name}, "/buckets", {}, true)
+  res = post("/buckets", :name=>bucket_name)
   raise Exception.new("unable to create bucket with name #{bucket_name} for bucket_test.rb")
unless res.code == 201
   #create blob:
   res = RestClient.put "#{API_URL}/buckets/#{bucket_name}/#{blob_name}", "This is the test
blob content", {:Authorization=>BASIC_AUTH, :content_type=>"text/plain", "X-Deltacloud-Blobmeta-Version"=>"1.0",
"X-Deltacloud-Blobmeta-Author"=>"herpyderp"}
@@ -158,10 +152,10 @@ end
 
 def delete_bucket_and_blob(bucket, blob)
   #  res = RestClient.delete "#{API_URL}/buckets/#{bucket}/#{blob}", {:Authorization=>BASIC_AUTH}
-  res = delete({}, "/buckets/#{bucket}/#{blob}")
+  res = delete("/buckets/#{bucket}/#{blob}")
   raise Exception.new("unable to delete blob with name #{blob} for bucket_test.rb") unless
res.code == 204
   #  res = RestClient.delete "#{API_URL}/buckets/#{bucket}", {:Authorization=>BASIC_AUTH}
-  res = delete({}, "/buckets/#{bucket}")
+  res = delete("/buckets/#{bucket}")
   raise Exception.new("unable to delete bucket with name #{bucket} for bucket_test.rb") unless
res.code == 204
 end
 


Mime
View raw message