From 9e371377de37f9384bffc92b6d2aa3af26bb79d8 Mon Sep 17 00:00:00 2001 From: Bohuslav Kabrda Date: Mon, 2 Jul 2012 10:27:09 +0200 Subject: [PATCH] Rework the quota mock testing to work and be more comfortable --- lib/fog/openstack/compute.rb | 13 ++++++++++++- lib/fog/openstack/requests/compute/get_quota.rb | 13 +------------ .../requests/compute/get_quota_defaults.rb | 13 +------------ .../openstack/requests/compute/update_quota.rb | 17 ++--------------- 4 files changed, 16 insertions(+), 40 deletions(-) diff --git a/lib/fog/openstack/compute.rb b/lib/fog/openstack/compute.rb index e9bddf29f..2f49ac8a6 100644 --- a/lib/fog/openstack/compute.rb +++ b/lib/fog/openstack/compute.rb @@ -182,7 +182,18 @@ module Fog :servers => {}, :key_pairs => {}, :security_groups => {}, - :addresses => {} + :addresses => {}, + :quota => { + 'metadata_items' => 128, + 'injected_file_content_bytes' => 10240, + 'injected_files' => 5, + 'gigabytes' => 1000, + 'ram' => 51200, + 'floating_ips' => 10, + 'instances' => 10, + 'volumes' => 10, + 'cores' => 20, + } } end end diff --git a/lib/fog/openstack/requests/compute/get_quota.rb b/lib/fog/openstack/requests/compute/get_quota.rb index 6d79b7944..feca55ab6 100644 --- a/lib/fog/openstack/requests/compute/get_quota.rb +++ b/lib/fog/openstack/requests/compute/get_quota.rb @@ -19,18 +19,7 @@ module Fog response = Excon::Response.new response.status = 200 response.body = { - 'quota_set' => { - 'metadata_items' => 128, - 'injected_file_content_bytes' => 10240, - 'injected_files' => 5, - 'gigabytes' => 1000, - 'ram' => 51200, - 'floating_ips' => 10, - 'instances' => 10, - 'volumes' => 10, - 'cores' => 20, - 'id' => tenant_id - } + 'quota_set' => (self.data[:quota_updated] or self.data[:quota]).merge({'id' => tenant_id}) } response end diff --git a/lib/fog/openstack/requests/compute/get_quota_defaults.rb b/lib/fog/openstack/requests/compute/get_quota_defaults.rb index a853c4c92..25944c170 100644 --- a/lib/fog/openstack/requests/compute/get_quota_defaults.rb +++ b/lib/fog/openstack/requests/compute/get_quota_defaults.rb @@ -19,18 +19,7 @@ module Fog response = Excon::Response.new response.status = 200 response.body = { - 'quota_set' => { - 'metadata_items' => 128, - 'injected_file_content_bytes' => 10240, - 'injected_files' => 5, - 'gigabytes' => 1000, - 'ram' => 51200, - 'floating_ips' => 10, - 'instances' => 10, - 'volumes' => 10, - 'cores' => 20, - 'id' => tenant_id - } + 'quota_set' => self.data[:quota].merge({'id' => tenant_id}) } response end diff --git a/lib/fog/openstack/requests/compute/update_quota.rb b/lib/fog/openstack/requests/compute/update_quota.rb index 9f9244a45..f5217d490 100644 --- a/lib/fog/openstack/requests/compute/update_quota.rb +++ b/lib/fog/openstack/requests/compute/update_quota.rb @@ -18,24 +18,11 @@ module Fog class Mock def update_quota(tenant_id, options = {}) - defaults = { - 'metadata_items' => 128, - 'injected_file_content_bytes' => 10240, - 'injected_files' => 5, - 'gigabytes' => 1000, - 'ram' => 51200, - 'floating_ips' => 10, - 'instances' => 10, - 'volumes' => 10, - 'cores' => 20, - 'id' => tenant_id - } - - defaults.merge options + self.data[:quota_updated] = self.data[:quota].merge options response = Excon::Response.new response.status = 200 - response.body = { 'quota_set' => options } + response.body = { 'quota_set' => self.data[:quota_updated] } response end