From 75f55c05789beb4fbe2391d33349058bba4ea5c0 Mon Sep 17 00:00:00 2001 From: chenjiankun Date: Thu, 12 Jan 2017 07:50:30 +0000 Subject: Create API to get a list of all test cases JIRA: YARDSTICK-456 Currently we do not have a API to get a list of all test cases; Currently the test case info is from the comment; So I create a API to get a list of all test cases; And create a 'description' attribute to record info of a test case; And use the CLI call this API; Change-Id: Ife800600446683664097835c7b9f11899c85771d Signed-off-by: chenjiankun --- tests/unit/benchmark/core/test_testcase.py | 4 ++-- tests/unit/cmd/commands/test_testcase.py | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 tests/unit/cmd/commands/test_testcase.py (limited to 'tests/unit') diff --git a/tests/unit/benchmark/core/test_testcase.py b/tests/unit/benchmark/core/test_testcase.py index c7da2de7c..1f5aad75e 100644 --- a/tests/unit/benchmark/core/test_testcase.py +++ b/tests/unit/benchmark/core/test_testcase.py @@ -28,13 +28,13 @@ class TestcaseUT(unittest.TestCase): def test_list_all(self): t = testcase.Testcase() result = t.list_all("") - self.assertEqual(result, True) + self.assertIsInstance(result, list) def test_show(self): t = testcase.Testcase() casename = Arg() result = t.show(casename) - self.assertEqual(result, True) + self.assertTrue(result) def main(): diff --git a/tests/unit/cmd/commands/test_testcase.py b/tests/unit/cmd/commands/test_testcase.py new file mode 100644 index 000000000..515784352 --- /dev/null +++ b/tests/unit/cmd/commands/test_testcase.py @@ -0,0 +1,21 @@ +import unittest +from mock import patch + +from yardstick.cmd.commands.testcase import TestcaseCommands + + +class TestcaseCommandsUT(unittest.TestCase): + @patch('yardstick.cmd.commands.testcase.TestcaseCommands._format_print') + @patch('yardstick.cmd.commands.client') + def test_do_list(self, mock_client, mock_print): + mock_client.get.return_value = {'result': []} + TestcaseCommands().do_list({}) + self.assertTrue(mock_print.called) + + +def main(): + unittest.main() + + +if __name__ == '__main__': + main() -- cgit 1.2.3-korg