Merge "[API] Remove the DeprecatedAPIClass"
This commit is contained in:
commit
e649dd5d09
17
rally/api.py
17
rally/api.py
@ -26,7 +26,7 @@ from oslo_config import cfg
|
||||
from requests.packages import urllib3
|
||||
|
||||
from rally.common import opts
|
||||
from rally.common.i18n import _, _LI, _LE, _LW
|
||||
from rally.common.i18n import _, _LI, _LE
|
||||
from rally.common import logging
|
||||
from rally.common import objects
|
||||
from rally.common.plugin import discover
|
||||
@ -1106,21 +1106,6 @@ class _Verification(object):
|
||||
"tests": results.tests}
|
||||
|
||||
|
||||
class _DeprecatedAPIClass(object):
|
||||
"""Deprecates direct usage of api classes."""
|
||||
def __init__(self, cls):
|
||||
self._cls = cls
|
||||
|
||||
def __getattr__(self, attr, default=None):
|
||||
LOG.warning(_LW("'%s' is deprecated since Rally 0.8.0 in favor of "
|
||||
"'rally.api.API' class.") % self._cls.__name__[1:])
|
||||
return getattr(self._cls, attr, default)
|
||||
|
||||
|
||||
Deployment = _DeprecatedAPIClass(_Deployment)
|
||||
Task = _DeprecatedAPIClass(_Task)
|
||||
|
||||
|
||||
class API(object):
|
||||
|
||||
CONFIG_SEARCH_PATHS = [sys.prefix + "/etc/rally", "~/.rally", "/etc/rally"]
|
||||
|
@ -101,4 +101,4 @@ class MultihostEngine(engine.Engine):
|
||||
def cleanup(self):
|
||||
subdeploys = db.deployment_list(parent_uuid=self.deployment["uuid"])
|
||||
for subdeploy in subdeploys:
|
||||
rally.api.Deployment.destroy(subdeploy["uuid"])
|
||||
rally.api._Deployment.destroy(subdeploy["uuid"])
|
||||
|
@ -63,7 +63,7 @@ class FileExporter(exporter.Exporter):
|
||||
|
||||
:param uuid: uuid of the task object
|
||||
"""
|
||||
task = api.Task.get_detailed(uuid)
|
||||
task = api._Task.get_detailed(uuid)
|
||||
|
||||
LOG.debug("Got the task object by it's uuid %s. " % uuid)
|
||||
|
||||
|
@ -108,9 +108,9 @@ class TestTaskSamples(unittest.TestCase):
|
||||
with open(full_path) as task_file:
|
||||
try:
|
||||
input_task = task_file.read()
|
||||
rendered_task = api.Task.render_template(input_task)
|
||||
rendered_task = api._Task.render_template(input_task)
|
||||
task_config = yaml.safe_load(rendered_task)
|
||||
api.Task.validate("MAIN", task_config)
|
||||
api._Task.validate("MAIN", task_config)
|
||||
except Exception as e:
|
||||
if not self._skip(six.text_type(e)):
|
||||
print(traceback.format_exc())
|
||||
|
@ -111,7 +111,7 @@ class MultihostEngineTestCase(test.TestCase):
|
||||
{"uuid": "uuid2"}]
|
||||
self.engine.cleanup()
|
||||
api_calls = [
|
||||
mock.call.Deployment.destroy("uuid1"),
|
||||
mock.call.Deployment.destroy("uuid2"),
|
||||
mock.call._Deployment.destroy("uuid1"),
|
||||
mock.call._Deployment.destroy("uuid2"),
|
||||
]
|
||||
self.assertEqual(api_calls, mock_api.mock_calls)
|
||||
|
@ -33,11 +33,11 @@ class FileExporterTestCase(test.TestCase):
|
||||
@mock.patch("rally.plugins.common.exporter.file_system.os.path.exists")
|
||||
@mock.patch.object(__builtin__, "open", autospec=True)
|
||||
@mock.patch("rally.plugins.common.exporter.file_system.json.dumps")
|
||||
@mock.patch("rally.api.Task.get_detailed")
|
||||
def test_file_exporter_export(self, mock_task_get_detailed, mock_dumps,
|
||||
@mock.patch("rally.api._Task")
|
||||
def test_file_exporter_export(self, mock___task, mock_dumps,
|
||||
mock_open, mock_exists):
|
||||
mock_exists.return_value = True
|
||||
mock_task_get_detailed.return_value = {"results": [{
|
||||
mock___task.get_detailed.return_value = {"results": [{
|
||||
"key": "fake_key",
|
||||
"data": {
|
||||
"raw": "bar_raw",
|
||||
@ -54,7 +54,7 @@ class FileExporterTestCase(test.TestCase):
|
||||
exporter.export("fake_uuid")
|
||||
|
||||
mock_open().__enter__().write.assert_called_once_with("fake_results")
|
||||
mock_task_get_detailed.assert_called_once_with("fake_uuid")
|
||||
mock___task.get_detailed.assert_called_once_with("fake_uuid")
|
||||
expected_dict = [
|
||||
{
|
||||
"load_duration": "foo_load_duration",
|
||||
@ -68,9 +68,9 @@ class FileExporterTestCase(test.TestCase):
|
||||
mock_dumps.assert_called_once_with(expected_dict, sort_keys=False,
|
||||
indent=4, separators=(",", ": "))
|
||||
|
||||
@mock.patch("rally.api.Task.get_detailed")
|
||||
def test_file_exporter_export_running_task(self, mock_task_get_detailed):
|
||||
mock_task_get_detailed.return_value = {"results": []}
|
||||
@mock.patch("rally.api._Task")
|
||||
def test_file_exporter_export_running_task(self, mock___task):
|
||||
mock___task.get_detailed.return_value = {"results": []}
|
||||
|
||||
exporter = file_system.FileExporter("file-exporter:///fake_path.json")
|
||||
self.assertRaises(exceptions.RallyException, exporter.export,
|
||||
|
Loading…
Reference in New Issue
Block a user