Try/except ODL push to DB until ODL tests are refactored 31/15631/1
authorMorgan Richomme <morgan.richomme@orange.com>
Wed, 15 Jun 2016 15:42:59 +0000 (17:42 +0200)
committerMorgan Richomme <morgan.richomme@orange.com>
Wed, 15 Jun 2016 15:42:59 +0000 (17:42 +0200)
Change-Id: I7919c69655ce43831d5269afc1d86bf2c929bb8f
Signed-off-by: Morgan Richomme <morgan.richomme@orange.com>
testcases/Controllers/ODL/odlreport2db.py

index 3eff400..075de5a 100644 (file)
@@ -110,17 +110,17 @@ def main(argv):
     # dictionary populated with data from xml file
     all_data = xmltodict.parse(xml_input)['robot']
 
-    data = parse_suites(all_data['suite']['suite'])
-    data['description'] = all_data['suite']['@name']
-    data['version'] = all_data['@generator']
-    data['test_project'] = "functest"
-    data['case_name'] = "ODL"
-    data['pod_name'] = pod
-    data['installer'] = installer
+    try:
+        data = parse_suites(all_data['suite']['suite'])
+        data['description'] = all_data['suite']['@name']
+        data['version'] = all_data['@generator']
+        data['test_project'] = "functest"
+        data['case_name'] = "ODL"
+        data['pod_name'] = pod
+        data['installer'] = installer
 
-    json.dumps(data, indent=4, separators=(',', ': '))
+        json.dumps(data, indent=4, separators=(',', ': '))
 
-    try:
         # example:
         # python odlreport2db.py -x ~/Pictures/Perso/odl/output3.xml
         #                        -i fuel
@@ -133,19 +133,16 @@ def main(argv):
         # start and stoptime have no real meaning
         start_time = time.time()
         stop_time = start_time
-        try:
-            tests_passed = 0
-            tests_failed = 0
-            for v in data['details']:
-                if v['test_status']['@status'] == "PASS":
-                    tests_passed += 1
-                else:
-                    tests_failed += 1
-
-            if (tests_failed < 1):
-                status = "PASS"
-        except:
-            print("Unable to set criteria" % sys.exc_info()[0])
+        tests_passed = 0
+        tests_failed = 0
+        for v in data['details']:
+            if v['test_status']['@status'] == "PASS":
+                tests_passed += 1
+            else:
+                tests_failed += 1
+
+        if (tests_failed < 1):
+            status = "PASS"
 
         functest_utils.push_results_to_db("functest",
                                           data['case_name'],
@@ -156,7 +153,7 @@ def main(argv):
                                           data)
 
     except:
-        print("Error pushing results into Database '%s'" % sys.exc_info()[0])
+        print("Error pushing ODL results into DB '%s'" % sys.exc_info()[0])
 
 
 if __name__ == "__main__":