deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [3/6] git commit: CIMI tests: add helper for post
Date Tue, 04 Dec 2012 15:39:56 GMT
CIMI tests: add helper for post

We need to make sure URL's are properly expanded when providers use
relative URL's. Therefore, using Restclient.post directly won't work.
TrackedAt: http://tracker.deltacloud.org/patch/b347ff0af114f74f485cc5fde619919c3ad5a1c0


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

Branch: refs/heads/master
Commit: fc232181d906d5a5cd2f3c168cf7fc861222a902
Parents: 73759a0
Author: David Lutterkort <lutter@redhat.com>
Authored: Mon Dec 3 23:36:40 2012 -0800
Committer: marios <marios@redhat.com>
Committed: Tue Dec 4 17:26:40 2012 +0200

----------------------------------------------------------------------
 tests/cimi/test_helper.rb |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/fc232181/tests/cimi/test_helper.rb
----------------------------------------------------------------------
diff --git a/tests/cimi/test_helper.rb b/tests/cimi/test_helper.rb
index 0e102c4..fccfcbc 100644
--- a/tests/cimi/test_helper.rb
+++ b/tests/cimi/test_helper.rb
@@ -141,6 +141,13 @@ module CIMI::Test::Methods
       RestClient.get absolute_url(path), headers(params)
     end
 
+    def post(path, body, params = {})
+      log_request(:post, path, :params => params, :body => body)
+      resp = RestClient.post absolute_url(path), body, headers(params)
+      log_response(:post, path, resp)
+      resp
+    end
+
     # Find the model class that can process the body of the HTTP response
     # +resp+
     def model_class(resp)
@@ -196,6 +203,22 @@ module CIMI::Test::Methods
       @log
     end
 
+    def log_request(method, path, opts = {})
+      log.debug("#{method.to_s.upcase} #{absolute_url(path)}")
+      if opts[:params]
+        h = headers(opts[:params])
+        h.keys.sort.each { |k| log.debug "  #{k}: #{h[k]}" }
+      end
+      log.debug opts[:body] if opts[:body]
+    end
+
+    def log_response(method, path, resp)
+      log.debug "--> #{resp.code} #{resp.headers[:content_type]}"
+      resp.headers.keys.each { |k| log.debug "#{k}: /#{resp.headers[k]}/" }
+      log.debug resp.body
+      log.debug "/#{method.to_s.upcase} #{absolute_url(path)}"
+    end
+
     def poll_state(machine, state)
       while not machine.state.upcase.eql?(state)
         puts state


Mime
View raw message