Return-Path: X-Original-To: apmail-deltacloud-dev-archive@www.apache.org Delivered-To: apmail-deltacloud-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D9172DB5E for ; Fri, 10 Aug 2012 13:04:43 +0000 (UTC) Received: (qmail 33946 invoked by uid 500); 10 Aug 2012 13:04:43 -0000 Delivered-To: apmail-deltacloud-dev-archive@deltacloud.apache.org Received: (qmail 33855 invoked by uid 500); 10 Aug 2012 13:04:43 -0000 Mailing-List: contact dev-help@deltacloud.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@deltacloud.apache.org Delivered-To: mailing list dev@deltacloud.apache.org Received: (qmail 33840 invoked by uid 99); 10 Aug 2012 13:04:43 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Aug 2012 13:04:43 +0000 X-ASF-Spam-Status: No, hits=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of mfojtik@redhat.com designates 209.132.183.28 as permitted sender) Received: from [209.132.183.28] (HELO mx1.redhat.com) (209.132.183.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Aug 2012 13:04:35 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q7AD4CjV007965 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 10 Aug 2012 09:04:12 -0400 Received: from [10.36.5.7] (vpn1-5-7.ams2.redhat.com [10.36.5.7]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q7AD4Aor026974 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Fri, 10 Aug 2012 09:04:12 -0400 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 6.0 \(1485\)) Subject: Re: [PATCH 1/2] API TESTS: refactoring of common code - avoid duplication From: Michal Fojtik In-Reply-To: <1344517364-7516-1-git-send-email-marios@redhat.com> Date: Fri, 10 Aug 2012 15:04:13 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <9B038E29-CEED-41CF-8920-2E152030C213@redhat.com> References: <1344517364-7516-1-git-send-email-marios@redhat.com> To: dev@deltacloud.apache.org X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 On Aug 9, 2012, at 3:02 PM, marios@redhat.com wrote: ACK. Small nits inline. > From: marios >=20 >=20 > Signed-off-by: marios > --- > tests/README | 15 ++++---- > tests/config.yaml | 10 +++--- > tests/deltacloud/instances_test.rb | 63 = +++++++++++------------------------- > tests/deltacloud/test_setup.rb | 27 +++++++++++---- > 4 files changed, 51 insertions(+), 64 deletions(-) >=20 > diff --git a/tests/deltacloud/test_setup.rb = b/tests/deltacloud/test_setup.rb > index e034493..6beceb1 100644 > --- a/tests/deltacloud/test_setup.rb > +++ b/tests/deltacloud/test_setup.rb > @@ -43,6 +43,12 @@ class String > return self.gsub(/es$/, '') if self =3D~ /sses$/ > self.gsub(/s$/, '') > end > + def pluralize > + return self + 'es' if self =3D~ /ess$/ > + return self[0, self.length-1] + "ies" if self =3D~ /ty$/ > + return self if self =3D~ /data$/ > + self + "s" > + end > end >=20 > class Array Why we need to have this in test_setup, when we already have core_ext with pluralize() method ? > @@ -83,12 +89,8 @@ module Deltacloud > @hash[driver]["bucket_locations"] > end >=20 > - def instances_config > - @hash[driver]["instances"] || {} > - end > - > - def preferred_provider > - @hash[driver]["preferred_provider"] > + def preferred > + @hash[driver]["preferred"] || {} > end >=20 > def driver > @@ -166,8 +168,8 @@ module Deltacloud::Test::Methods > end >=20 > def post(path, post_body, params=3D{}) > - if api.preferred_provider and not params[:provider] > - params[:provider] =3D api.preferred_provider > + if api.preferred["provider"] and not params[:provider] > + params[:provider] =3D api.preferred["provider"] > end > url, headers =3D process_url_params(path, params) > RestClient.post url, post_body, headers > @@ -204,6 +206,15 @@ module Deltacloud::Test::Methods > name.insert(0, "apitest") > end >=20 > + def get_a(item) > + if api.preferred[item] > + item_id =3D api.preferred[item] > + else > + item_list =3D get("/#{item.pluralize}") > + item_id =3D = (item_list.xml/"#{item.pluralize}/#{item}").to_a.choice[:id] > + end > + end > + > private >=20 > def process_url_params(path, params) > --=20 > 1.7.6.5 >=20