mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[rackspace|compute] updated mocking framework to support any flavor or image
This commit is contained in:
parent
b6eb57196d
commit
c5e4f8eed5
5 changed files with 21 additions and 10 deletions
|
@ -1,6 +1,9 @@
|
|||
module Fog
|
||||
module Rackspace
|
||||
module MockData
|
||||
|
||||
NOT_FOUND_ID = "NOT-FOUND"
|
||||
|
||||
def data
|
||||
@@data ||= Hash.new do |hash, key|
|
||||
hash[key] = begin
|
||||
|
@ -101,12 +104,13 @@ module Fog
|
|||
}
|
||||
|
||||
#Mock Data Hash
|
||||
{
|
||||
h = {
|
||||
#Compute V2
|
||||
:flavors => {flavor_id => flavor},
|
||||
:images => {image_id => image},
|
||||
:flavors => Hash.new { |h,k| h[k] = flavor unless k == NOT_FOUND_ID},
|
||||
:images => Hash.new { |h,k| h[k] = image unless k == NOT_FOUND_ID },
|
||||
:networks => Hash.new { |h,k| h[k] = network unless k == NOT_FOUND_ID },
|
||||
|
||||
:servers => {},
|
||||
:networks => { network_id => network },
|
||||
|
||||
#Block Storage
|
||||
:volumes => {},
|
||||
|
@ -114,6 +118,13 @@ module Fog
|
|||
:volume_attachments => [],
|
||||
:volume_types => {volume_type1_id => volume_type1, volume_type2_id => volume_type2},
|
||||
}
|
||||
|
||||
# seed with initial data
|
||||
h[:flavors][flavor_id] = flavor
|
||||
h[:images][image_id] = image
|
||||
h[:networks][network_id] = network
|
||||
|
||||
h
|
||||
end
|
||||
end[@rackspace_api_key]
|
||||
end
|
||||
|
|
|
@ -12,6 +12,6 @@ Shindo.tests('Fog::Compute::RackspaceV2 | flavors', ['rackspace']) do
|
|||
end
|
||||
|
||||
tests("failure").returns(nil) do
|
||||
service.flavors.get('some_random_identity')
|
||||
service.flavors.get(Fog::Rackspace::MockData::NOT_FOUND_ID)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,6 +15,6 @@ Shindo.tests('Fog::Compute::RackspaceV2 | images', ['rackspace']) do
|
|||
end
|
||||
|
||||
tests("failure").returns(nil) do
|
||||
service.images.get('some_random_identity')
|
||||
service.images.get(Fog::Rackspace::MockData::NOT_FOUND_ID)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -57,12 +57,12 @@ Shindo.tests('Fog::Compute[:rackspace] | image requests', ['rackspace']) do
|
|||
tests('failure') do
|
||||
|
||||
tests('#delete_image(0)').raises(Excon::Errors::BadRequest) do
|
||||
@service.delete_image(0)
|
||||
@service.delete_image(Fog::Rackspace::MockData::NOT_FOUND_ID)
|
||||
end
|
||||
|
||||
tests('#get_image_details(0)').raises(Fog::Compute::Rackspace::NotFound) do
|
||||
pending if Fog.mocking?
|
||||
@service.get_image_details(0)
|
||||
@service.get_image_details(Fog::Rackspace::MockData::NOT_FOUND_ID)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -59,11 +59,11 @@ Shindo.tests('Fog::Compute::RackspaceV2 | image_tests', ['rackspace']) do
|
|||
|
||||
tests('failure') do
|
||||
tests('#delete_image').raises(Excon::Errors::BadRequest) do
|
||||
Fog::Compute[:rackspace].delete_image(0)
|
||||
Fog::Compute[:rackspace].delete_image(Fog::Rackspace::MockData::NOT_FOUND_ID)
|
||||
end
|
||||
|
||||
tests('#get_image').raises(Fog::Compute::RackspaceV2::NotFound) do
|
||||
service.get_image(0)
|
||||
service.get_image(Fog::Rackspace::MockData::NOT_FOUND_ID)
|
||||
end
|
||||
end
|
||||
ensure
|
||||
|
|
Loading…
Reference in a new issue