Print all the Parser test output to a log file
[functest.git] / testcases / features / promise.py
index 170f754..3f58dce 100755 (executable)
@@ -9,20 +9,18 @@
 #
 # Maintainer : jose.lausuch@ericsson.com
 #
-import argparse
 import json
 import os
 import subprocess
 import time
 
+import argparse
 import functest.utils.functest_logger as ft_logger
 import functest.utils.functest_utils as functest_utils
 import functest.utils.openstack_utils as openstack_utils
 import keystoneclient.v2_0.client as ksclient
-from neutronclient.v2_0 import client as ntclient
 import novaclient.client as nvclient
-import yaml
-
+from neutronclient.v2_0 import client as ntclient
 
 parser = argparse.ArgumentParser()
 
@@ -32,11 +30,9 @@ parser.add_argument("-r", "--report",
                     action="store_true")
 args = parser.parse_args()
 
-with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f:
-    functest_yaml = yaml.safe_load(f)
+functest_yaml = functest_utils.get_functest_yaml()
 
 dirs = functest_yaml.get('general').get('directories')
-FUNCTEST_REPO = dirs.get('dir_repo_functest')
 PROMISE_REPO = dirs.get('dir_repo_promise')
 TEST_DB = functest_yaml.get('results').get('test_db_url')
 
@@ -87,7 +83,7 @@ def main():
     logger.info("Creating tenant '%s'..." % TENANT_NAME)
     tenant_id = openstack_utils.create_tenant(
         keystone, TENANT_NAME, TENANT_DESCRIPTION)
-    if tenant_id == '':
+    if not tenant_id:
         logger.error("Error : Failed to create %s tenant" % TENANT_NAME)
         exit(-1)
     logger.debug("Tenant '%s' created successfully." % TENANT_NAME)
@@ -114,7 +110,7 @@ def main():
     user_id = openstack_utils.create_user(
         keystone, USER_NAME, USER_PWD, None, tenant_id)
 
-    if user_id == '':
+    if not user_id:
         logger.error("Error : Failed to create %s user" % USER_NAME)
         exit(-1)
     logger.debug("User '%s' created successfully." % USER_NAME)
@@ -171,7 +167,7 @@ def main():
                                                       SUBNET_NAME,
                                                       ROUTER_NAME,
                                                       SUBNET_CIDR)
-    if network_dic is False:
+    if not network_dic:
         logger.error("Failed to create the private network...")
         exit(-1)