Merge "Update release note for Colorado 2.0"
[yardstick.git] / yardstick / cmd / commands / testcase.py
index c37fcc2..cb76c7a 100644 (file)
@@ -8,12 +8,15 @@
 ##############################################################################
 
 """ Handler for yardstick command 'testcase' """
-from yardstick.cmd import print_hbar
-from yardstick.common.task_template import TaskTemplate
 import os
 import yaml
 import sys
 
+from yardstick.cmd import print_hbar
+from yardstick.common.task_template import TaskTemplate
+from yardstick.common.utils import cliargs
+from yardstick.definitions import YARDSTICK_ROOT_PATH
+
 
 class TestcaseCommands(object):
     '''Testcase commands.
@@ -21,7 +24,7 @@ class TestcaseCommands(object):
        Set of commands to discover and display test cases.
     '''
     def __init__(self):
-        self.test_case_path = 'tests/opnfv/test_cases/'
+        self.test_case_path = YARDSTICK_ROOT_PATH + 'tests/opnfv/test_cases/'
         self.testcase_list = []
 
     def do_list(self, args):
@@ -42,6 +45,26 @@ class TestcaseCommands(object):
         self._format_print(self.testcase_list)
         return True
 
+    @cliargs("casename", type=str, help="test case name", nargs=1)
+    def do_show(self, args):
+        '''Show details of a specific test case'''
+        testcase_name = args.casename[0]
+        testcase_path = self.test_case_path + testcase_name + ".yaml"
+        try:
+            with open(testcase_path) as f:
+                try:
+                    testcase_info = f.read()
+                    print testcase_info
+
+                except Exception as e:
+                    print(("Failed to load test cases:"
+                           "\n%(testcase_file)s\n%(err)s\n")
+                          % {"testcase_file": testcase_path, "err": e})
+                    raise e
+        except IOError as ioerror:
+            sys.exit(ioerror)
+        return True
+
     def _get_record(self, testcase_file):
 
         try: