Merge "[raas] Adding a decorator of api_wrapper"

This commit is contained in:
Jenkins 2017-06-09 13:47:35 +00:00 committed by Gerrit Code Review
commit e85facaf05
2 changed files with 10 additions and 6 deletions

View File

@ -15,11 +15,11 @@
import inspect import inspect
import json import json
import mock
import os import os
import re import re
import traceback import traceback
import mock
import yaml import yaml
import rally import rally
@ -57,7 +57,8 @@ class TaskSampleTestCase(test.TestCase):
with open(full_path) as task_file: with open(full_path) as task_file:
try: try:
task_config = yaml.safe_load( 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, eng = engine.TaskEngine(task_config,
mock.MagicMock(), mock.Mock()) mock.MagicMock(), mock.Mock())
eng.validate(only_syntax=True) eng.validate(only_syntax=True)
@ -84,7 +85,7 @@ class TaskSampleTestCase(test.TestCase):
with open(full_path) as task_file: with open(full_path) as task_file:
try: try:
json.loads(self.rapi.task.render_template( json.loads(self.rapi.task.render_template(
task_file.read())) task_template=task_file.read()))
except Exception: except Exception:
print(traceback.format_exc()) print(traceback.format_exc())
self.fail("Invalid JSON file: %s" % full_path) 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): if os.path.exists(yaml_path) and os.path.exists(json_path):
with open(json_path) as json_file: with open(json_path) as json_file:
json_config = yaml.safe_load( 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: with open(yaml_path) as yaml_file:
yaml_config = yaml.safe_load( 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, self.assertEqual(json_config, yaml_config,
"Sample task configs are not equal:" "Sample task configs are not equal:"
"\n%s\n%s" % (yaml_path, json_path)) "\n%s\n%s" % (yaml_path, json_path))

View File

@ -57,7 +57,8 @@ class RallyJobsTestCase(test.TestCase):
"presenatation" % args_file) "presenatation" % args_file)
task_inst = api._Task(api.API(skip_db_check=True)) 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) task = yaml.safe_load(task)
eng = engine.TaskEngine(task, mock.MagicMock(), eng = engine.TaskEngine(task, mock.MagicMock(),