From 6cef6a9a0371bc23d09d6c47d95f7eb80e30fc9f Mon Sep 17 00:00:00 2001 From: Dmitrii Shcherbakov Date: Sun, 17 Mar 2019 02:57:35 +0300 Subject: [PATCH] Fix test_time_hook functional test The problematic code that causes "TypeError: string indices must be integers": -> self.assertEqual( expected, sorted(hook_results, key=lambda i: list( i["config"]["trigger"].values())[0]["unit"])) (Pdb) hook_results[0]["config"]["trigger"] {'name': 'event', 'args': {'unit': 'iteration', 'at': [5]}} values[0] is not always a dict with a unit element: (Pdb) hook_results[0]["config"]["trigger"].values() dict_values(['event', {'unit': 'iteration', 'at': [5]}]) We should use args['args']['unit'] instead. Change-Id: I42db6045ae88c34d3576beb737bb7e955c5f2132 Needed-By: I4991acccefd4754e209feafd5e24d03c76c283f8 --- tests/functional/test_cli_task.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/functional/test_cli_task.py b/tests/functional/test_cli_task.py index f30d1415ee..bcf26ec22d 100644 --- a/tests/functional/test_cli_task.py +++ b/tests/functional/test_cli_task.py @@ -1420,8 +1420,7 @@ class HookTestCase(unittest.TestCase): self.assertEqual( expected, sorted(hook_results, - key=lambda i: list( - i["config"]["trigger"].values())[0]["unit"])) + key=lambda i: i["config"]["trigger"]["args"]["unit"])) self._assert_results_time(hook_results) def test_import_hook_result(self):