[Verify] Moving compare.mako to rally/ui/templates/verification

The compare.mako file was moved from rally/verification/tempest/report_templates
to rally/ui/templates/verification. The report_templates folder was removed.

Change-Id: Ic1dcb4c82901c95826b808f9632df9a10115fd87
This commit is contained in:
Yaroslav Lobankov 2015-10-20 12:48:44 +03:00
parent f76ccdcf40
commit 28facb31ad
3 changed files with 24 additions and 21 deletions

View File

@ -11,7 +11,7 @@
# under the License.
"""Output verification comparison results in html."""
import os
from rally.ui import utils as ui_utils
__description__ = "List differences between two verification runs"
__title__ = "Verification Comparison"
@ -19,8 +19,6 @@ __version__ = "0.1"
def create_report(results):
import mako.template
template_kw = {
"heading": {
"title": __title__,
@ -31,11 +29,7 @@ def create_report(results):
"results": results
}
template_path = os.path.join(os.path.dirname(__file__),
"report_templates",
"compare.mako")
template = ui_utils.get_template("verification/compare.mako")
output = template.render(**template_kw)
with open(template_path) as f:
template = mako.template.Template(f.read(), strict_undefined=True)
output = template.render(**template_kw)
return output.encode("utf8")
return output.encode("utf8")

View File

@ -18,7 +18,8 @@ from tests.unit import test
class Compare2HtmlTestCase(test.TestCase):
def test_main(self):
@mock.patch("rally.ui.utils.get_template")
def test_main(self, mock_get_template):
results = [{"val2": 0.0111, "field": u"time", "val1": 0.0222,
"type": "CHANGED", "test_name": u"test.one"},
{"val2": 0.111, "field": u"time", "val1": 0.222,
@ -26,14 +27,22 @@ class Compare2HtmlTestCase(test.TestCase):
{"val2": 1.11, "field": u"time", "val1": 2.22,
"type": "CHANGED", "test_name": u"test.three"}]
fake_kw = {"heading":
{"title": compare2html.__title__,
"description": compare2html.__description__,
"parameters": [("Difference Count", len(results))]
},
"generator": "compare2html %s" % compare2html.__version__,
"results": results}
fake_template_kw = {
"heading": {
"title": compare2html.__title__,
"description": compare2html.__description__,
"parameters": [("Difference Count", len(results))]
},
"generator": "compare2html %s" % compare2html.__version__,
"results": results
}
with mock.patch("mako.template.Template") as mock_mako:
compare2html.create_report(results)
mock_mako().render.assert_called_once_with(**fake_kw)
template_mock = mock.MagicMock()
mock_get_template.return_value = template_mock
output_mock = mock.MagicMock()
template_mock.render.return_value = output_mock
compare2html.create_report(results)
mock_get_template.assert_called_once_with("verification/compare.mako")
template_mock.render.assert_called_once_with(**fake_template_kw)
output_mock.encode.assert_called_once_with("utf8")