From f05cd36634c17ad970797e813d8dcfe9a97e8465 Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Thu, 13 Dec 2012 15:25:39 -0800 Subject: [PATCH] marvin: assertions with messages for common.py --- tools/marvin/marvin/integration/lib/common.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/marvin/marvin/integration/lib/common.py b/tools/marvin/marvin/integration/lib/common.py index 5f90110c367..69aa733420e 100644 --- a/tools/marvin/marvin/integration/lib/common.py +++ b/tools/marvin/marvin/integration/lib/common.py @@ -81,7 +81,7 @@ def get_zone(apiclient, services=None): zones = apiclient.listZones(cmd) if isinstance(zones, list): - assert len(zones) > 0 + assert len(zones) > 0, "There are no available zones in the deployment" return zones[0] else: raise Exception("Failed to find specified zone.") @@ -100,7 +100,7 @@ def get_pod(apiclient, zoneid, services=None): pods = apiclient.listPods(cmd) if isinstance(pods, list): - assert len(pods) > 0 + assert len(pods) > 0, "No pods found for zone %s"%zoneid return pods[0] else: raise Exception("Exception: Failed to find specified pod.") @@ -129,10 +129,11 @@ def get_template(apiclient, zoneid, ostype, services=None): list_templates = apiclient.listTemplates(cmd) - assert len(list_templates) > 0 - for template in list_templates: - if template.ostypeid == ostypeid: - return template + if isinstance(list_templates, list): + assert len(list_templates) > 0, "received empty response on template of type %s"%ostype + for template in list_templates: + if template.ostypeid == ostypeid: + return template raise Exception("Exception: Failed to find template with OSTypeID: %s" % ostypeid)