From d83a7621dcf04718a5508d2e9e533581be35dcd0 Mon Sep 17 00:00:00 2001 From: Hai Shi Date: Mon, 8 May 2017 21:58:38 +0800 Subject: [PATCH] [raas] Adding a decorator of api_wrapper If we send a request to remote server, we need api_wrapper to restore enough info which includes requests' path and the type of request. Change-Id: Ia3add4e0827462b7e45062aa801ecb9a1a129d18 --- tests/unit/doc/test_task_samples.py | 13 ++++++++----- tests/unit/rally_jobs/test_jobs.py | 3 ++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/unit/doc/test_task_samples.py b/tests/unit/doc/test_task_samples.py index 08339a5a..a138bed2 100644 --- a/tests/unit/doc/test_task_samples.py +++ b/tests/unit/doc/test_task_samples.py @@ -15,11 +15,11 @@ import inspect import json -import mock import os import re import traceback +import mock import yaml import rally @@ -57,7 +57,8 @@ class TaskSampleTestCase(test.TestCase): with open(full_path) as task_file: try: task_config = yaml.safe_load( - self.rapi.task.render_template(task_file.read())) + self.rapi.task.render_template( + task_template=task_file.read())) eng = engine.TaskEngine(task_config, mock.MagicMock(), mock.Mock()) eng.validate(only_syntax=True) @@ -84,7 +85,7 @@ class TaskSampleTestCase(test.TestCase): with open(full_path) as task_file: try: json.loads(self.rapi.task.render_template( - task_file.read())) + task_template=task_file.read())) except Exception: print(traceback.format_exc()) self.fail("Invalid JSON file: %s" % full_path) @@ -125,10 +126,12 @@ class TaskSampleTestCase(test.TestCase): if os.path.exists(yaml_path) and os.path.exists(json_path): with open(json_path) as json_file: json_config = yaml.safe_load( - self.rapi.task.render_template(json_file.read())) + self.rapi.task.render_template( + task_template=json_file.read())) with open(yaml_path) as yaml_file: yaml_config = yaml.safe_load( - self.rapi.task.render_template(yaml_file.read())) + self.rapi.task.render_template( + task_template=yaml_file.read())) self.assertEqual(json_config, yaml_config, "Sample task configs are not equal:" "\n%s\n%s" % (yaml_path, json_path)) diff --git a/tests/unit/rally_jobs/test_jobs.py b/tests/unit/rally_jobs/test_jobs.py index e8b96e8f..90e740f5 100644 --- a/tests/unit/rally_jobs/test_jobs.py +++ b/tests/unit/rally_jobs/test_jobs.py @@ -57,7 +57,8 @@ class RallyJobsTestCase(test.TestCase): "presenatation" % args_file) task_inst = api._Task(api.API(skip_db_check=True)) - task = task_inst.render_template(task_file.read(), **args) + task = task_inst.render_template( + task_template=task_file.read(), **args) task = yaml.safe_load(task) eng = engine.TaskEngine(task, mock.MagicMock(),