network tests

This commit is contained in:
amartynov 2014-06-23 19:29:12 +04:00
parent 4585a7f26f
commit 5893398314
3 changed files with 77 additions and 0 deletions

View File

@ -0,0 +1,59 @@
@network
Feature: Networks
@openstack
Scenario: Get list of openstack networks
When I send GET '/v2.0/networks/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:
"""
[
{
"cidr": "192.168.0.0/16",
"name": "private",
"id": "net_id"
}
]
"""
@ec2
Scenario: Get list of ec2 networks
When I send GET '/v2.0/networks/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:
"""
[
{
"cidr": "192.168.0.0/16",
"name": "private",
"zone": "net_zone",
"vpcId": "vpcId",
"subnetId": "subnetId"
}
]
"""
@static
Scenario: Get list of static networks
When I send GET '/v2.0/networks/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
@static
Scenario: Get networks list of static provider without 'Accept' header
When I send GET '/v2.0/networks/static' query without headers 'Accept'
Then response should be '406'
Scenario: Get networks list of unknown provider
When I send GET '/v2.0/networks/foo' query
Then response should be '404'
Scenario: Get networks list of unknown provider without 'Accept' header
When I send GET '/v2.0/networks/foo' query without headers 'Accept'
Then response should be '406'

View File

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

View File

@ -35,6 +35,10 @@ module Provider
[]
end
def networks_detail
self.networks
end
def servers
@@mongo.servers_find({:provider => PROVIDER}).map{|s| s.to_hash}
end