incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject svn commit: r979645 - in /incubator/deltacloud/trunk/client: lib/deltacloud.rb specs/hardware_profiles_spec.rb
Date Tue, 27 Jul 2010 11:29:24 GMT
Author: mfojtik
Date: Tue Jul 27 11:29:23 2010
New Revision: 979645

URL: http://svn.apache.org/viewvc?rev=979645&view=rev
Log:
Fixed hardware_profiles method in client which returns same values

Modified:
    incubator/deltacloud/trunk/client/lib/deltacloud.rb
    incubator/deltacloud/trunk/client/specs/hardware_profiles_spec.rb

Modified: incubator/deltacloud/trunk/client/lib/deltacloud.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client/lib/deltacloud.rb?rev=979645&r1=979644&r2=979645&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client/lib/deltacloud.rb (original)
+++ incubator/deltacloud/trunk/client/lib/deltacloud.rb Tue Jul 27 11:29:23 2010
@@ -191,12 +191,13 @@ module DeltaCloud
                   end
                 # Property attribute is handled differently
                 when "property":
-                  define_method :"#{attribute['name'].sanitize}" do
-                    if attribute['value'] =~ /^(\d+)$/
-                      DeltaCloud::HWP::FloatProperty.new(attribute, attribute['name'])
-                    else
-                      DeltaCloud::HWP::Property.new(attribute, attribute['name'])
-                    end
+                  attr_accessor :"#{attribute['name'].sanitize}"
+                  if attribute['value'] =~ /^(\d+)$/
+                    obj.send(:"#{attribute['name'].sanitize}=",
+                      DeltaCloud::HWP::FloatProperty.new(attribute, attribute['name']))
+                  else
+                    obj.send(:"#{attribute['name'].sanitize}=",
+                      DeltaCloud::HWP::Property.new(attribute, attribute['name']))
                   end
                 # Public and private addresses are returned as Array
                 when "public_addresses", "private_addresses":

Modified: incubator/deltacloud/trunk/client/specs/hardware_profiles_spec.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client/specs/hardware_profiles_spec.rb?rev=979645&r1=979644&r2=979645&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client/specs/hardware_profiles_spec.rb (original)
+++ incubator/deltacloud/trunk/client/specs/hardware_profiles_spec.rb Tue Jul 27 11:29:23
2010
@@ -37,9 +37,7 @@ describe "hardware_profiles" do
       hardware_profiles.each do |hwp|
         hwp.uri.should_not be_nil
         hwp.uri.should be_a(String)
-        prop_check(hwp.architecture, String)
-        prop_check(hwp.storage, Float)
-        prop_check(hwp.memory, Float)
+        prop_check(hwp.architecture, String)  if hwp.architecture
       end
     end
   end
@@ -61,6 +59,14 @@ describe "hardware_profiles" do
     end
   end
 
+  it "should allow fetching different hardware_profiles" do
+    client = DeltaCloud.new( API_NAME, API_PASSWORD, API_URL )
+    hwp1 = client.hardware_profile( 'm1-small' )
+    hwp2 = client.hardware_profile( 'm1-xlarge' )
+    hwp1.storage.value.should_not eql(hwp2.storage.value)
+    hwp1.memory.value.should_not eql(hwp2.memory.value)
+  end
+
   it "should allow fetching a hardware_profile by URI" do
     DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
       hwp = client.fetch_hardware_profile( API_URL + '/hardware_profiles/m1-small' )



Mime
View raw message