ACK series - bar minor nit inline (rmd3 test fails for me because of it) - NIT2 is the actual error, NIT1 is just minor optimisation:
On 20/02/13 00:53, rla...@redhat.com wrote: > From: Ronelle Landy <rla...@redhat.com> > > --- > tests/cimi/rmd3_test.rb | 53 ++++++++++------- > tests/cimi/rmd4_test.rb | 147 +++++++++++++++++++++++--------------------- > tests/cimi/test_helper.rb | 21 +++++++ > 3 files changed, 130 insertions(+), 91 deletions(-) > <SNIP> > diff --git a/tests/cimi/rmd4_test.rb b/tests/cimi/rmd4_test.rb > index b0d6c8c..9375661 100644 > --- a/tests/cimi/rmd4_test.rb > +++ b/tests/cimi/rmd4_test.rb > @@ -27,6 +27,8 @@ class MachinesRMDInitialStates < CIMI::Test::Spec > INITIAL_STATES_CAPABILITY_URI = > "http://schemas.dmtf.org/cimi/1/capability/Machine/InitialStates" > + # Execute a GET /machines/new_machine_id operation to return the > machine > + # stable initial state > + it "should have a state equal to the specified initial state" do > + machine = get(@@rmd4_created_machines[chosen_initial_state], > :accept=>:json) > + 5.times do |j| > + machine = get(@@rmd4_created_machines[chosen_initial_state], > :accept=>:json) > + break if > machine.json["state"].upcase.eql?(chosen_initial_state.upcase) > + puts machine.json["state"] > + puts 'waiting for machine to be: ' + chosen_initial_state > + sleep(5) > + end unless > machine.json["state"].upcase.eql?(chosen_initial_state.upcase) NIT 1: since you're sending a revision you can probably move the "machine = get" to the end of the loop , e.g. after sleep - otherwise you're making one extra request (first time around) <SNIP> > diff --git a/tests/cimi/test_helper.rb b/tests/cimi/test_helper.rb > index 96e94f6..37f0166 100644 > --- a/tests/cimi/test_helper.rb > +++ b/tests/cimi/test_helper.rb > @@ -129,6 +129,17 @@ module CIMI::Test::Methods > discover_uri_for(op, "", subcollection_ops) > end > > + def discover_uri_for_rmd(resource_uri, rmd_type, rmd_uri) > + cep_json = cep(:accept => :json) > + rmd_coll = get cep_json.json["resourceMetadata"]["href"], :accept => > :json > + #get the collection index: > + collection_index = rmd_coll.json["resourceMetadata"].index {|rmd| > rmd["typeUri"] == resource_uri} > + unless > rmd_coll.json["resourceMetadata"][collection_index][rmd_type].nil?() > + rmd_index = > rmd_coll.json["resourceMetadata"][collection_index][rmd_type].index {|rmd| > rmd["uri"] == rmd_uri} > + end > + raise "Couldn't discover the #{rmd_uri} URI" if rmd_index.nil?() || > rmd_index.empty?() NIT 2: this was giving me an error because rmd_index.empty?() ===> NoMethodError Exception: undefined method `empty?' for 0:Fixnum it should be sufficient to just use raise "Couldn't discover the #{rmd_uri} URI" unless rmd_index marios