flavor tests

This commit is contained in:
amartynov 2014-06-20 12:59:17 +04:00
parent 10eaf25454
commit bfbf56e08d
9 changed files with 77 additions and 14 deletions

View File

@ -1,3 +1,4 @@
# encoding: UTF-8
module I18n module I18n
@@lang = {} @@lang = {}

View File

@ -1,3 +1,4 @@
# encoding: UTF-8
ru: ru:
config: config:
invalid: invalid:

View File

@ -0,0 +1,47 @@
Feature: flavors
@flavor
Scenario: Get list of openstack flavors
When I send GET '/v2.0/flavors/openstack' query
Then response should be '200'
And the Content-Type header should include 'application/json'
And the JSON response should be an array
And response array should contains elements like:
"""
[
{
"id" => "flavor_id",
"v_cpus" => "v_cpus",
"ram" => "ram",
"disk" => "disk"
}
]
"""
@flavor
Scenario: Get list of ec2 flavors
When I send GET '/v2.0/flavors/ec2' query
Then response should be '200'
And the Content-Type header should include 'application/json'
And the JSON response should be an array
And response array should contains elements like:
"""
[
{
"id": "t1.micro",
"cores": 2,
"disk": 0,
"name": "Micro Instance",
"ram": 613
}
]
"""
@flavor
Scenario: Get list of static flavors
When I send GET '/v2.0/flavors/static' query
Then response should be '200'
And the Content-Type header should include 'application/json'
And the JSON response should be an array
And response array should be empty

View File

@ -5,7 +5,7 @@ Feature: Manage images
Then response should be '200' Then response should be '200'
And the Content-Type header should include 'application/json' And the Content-Type header should include 'application/json'
And the JSON response should be an array And the JSON response should be an array
And response should be JSON, images list: And response array should contains elements like:
""" """
[ [
{ {

View File

@ -4,6 +4,7 @@ DEFAULT_HEADERS = {
'Accept' => 'application/json' 'Accept' => 'application/json'
} }
When(/^I send GET '(.*)' query$/) do |path| When(/^I send GET '(.*)' query$/) do |path|
puts path
get(path, {}, DEFAULT_HEADERS) get(path, {}, DEFAULT_HEADERS)
end end

View File

@ -23,6 +23,7 @@ Then(/^the JSON response should be a hash$/) do
assert body.is_a?(Hash), "Body is not a hash" assert body.is_a?(Hash), "Body is not a hash"
end end
=begin
Then(/^response should be JSON, images list:$/) do |string| Then(/^response should be JSON, images list:$/) do |string|
src_image = JSON.parse(string).first src_image = JSON.parse(string).first
image = JSON.parse(last_response.body).first image = JSON.parse(last_response.body).first
@ -30,6 +31,7 @@ Then(/^response should be JSON, images list:$/) do |string|
assert image.key?(key), "Image has no key '#{key}'" assert image.key?(key), "Image has no key '#{key}'"
end end
end end
=end
Then(/^response should be JSON, image object:$/) do |string| Then(/^response should be JSON, image object:$/) do |string|
src_image = JSON.parse(string) src_image = JSON.parse(string)

View File

@ -0,0 +1,14 @@
Then(/^response array should contains elements like:$/) do |string|
src = JSON.parse(string).first
array = JSON.parse(last_response.body)
array.each do |e|
src.each do |key, value|
assert e.key?(key), "Element #{e.inspect} has no key '#{key}'"
end
end
end
Then(/^response array should be empty$/) do
array = JSON.parse(last_response.body)
assert array.empty?, "Array is not empty"
end

View File

@ -182,6 +182,9 @@ module Provider
end end
end end
def compute
connection_compute(connection_options)
end
private private
def convert_groups list def convert_groups list
res = {} res = {}
@ -231,10 +234,5 @@ module Provider
end end
r r
end end
private
def compute
connection_compute(connection_options)
end
end end
end end

View File

@ -182,6 +182,13 @@ module Provider
return nil return nil
end end
def compute
connection_compute(self.connection_options)
end
def network
connection_network(self.connection_options)
end
private private
def convert_groups list def convert_groups list
res = {} res = {}
@ -203,13 +210,5 @@ module Provider
res res
end end
def compute
connection_compute(self.connection_options)
end
def network
connection_network(self.connection_options)
end
end end
end end