tests with config
This commit is contained in:
parent
bfbf56e08d
commit
2b18cefb82
@ -10,10 +10,10 @@ Feature: flavors
|
||||
"""
|
||||
[
|
||||
{
|
||||
"id" => "flavor_id",
|
||||
"v_cpus" => "v_cpus",
|
||||
"ram" => "ram",
|
||||
"disk" => "disk"
|
||||
"id": "flavor_id",
|
||||
"v_cpus": "v_cpus",
|
||||
"ram": "ram",
|
||||
"disk": "disk"
|
||||
}
|
||||
]
|
||||
"""
|
||||
|
||||
@ -4,7 +4,6 @@ DEFAULT_HEADERS = {
|
||||
'Accept' => 'application/json'
|
||||
}
|
||||
When(/^I send GET '(.*)' query$/) do |path|
|
||||
puts path
|
||||
get(path, {}, DEFAULT_HEADERS)
|
||||
end
|
||||
|
||||
|
||||
@ -25,8 +25,23 @@ class RequestSender
|
||||
@last_res = nil
|
||||
$test_hash = Hash.new
|
||||
|
||||
# config:
|
||||
# host=<host>
|
||||
# port=<port>
|
||||
# username=<user>
|
||||
# password=<psw>
|
||||
def initialize
|
||||
file = "tests.conf"
|
||||
abort("File does not exist: #{File.absolute_path(file)}") unless File.exists?(file)
|
||||
@config = {}
|
||||
File.open(file).each_line do |l|
|
||||
b = l.split("=")
|
||||
@config[ b[0] ] = b[1].strip
|
||||
end
|
||||
end
|
||||
|
||||
def host
|
||||
"http://#{HOST}:#{PORT}"
|
||||
"http://#{@config["host"]}:#{@config["port"]}"
|
||||
end
|
||||
|
||||
def last_response
|
||||
@ -54,7 +69,7 @@ class RequestSender
|
||||
|
||||
def submit
|
||||
http = HTTPClient.new
|
||||
http.set_auth(host, USERNAME, PASSWORD)
|
||||
http.set_auth(nil, @config["username"], @config["password"])
|
||||
res = yield http
|
||||
@last_res = res
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user