28facb31ad
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
49 lines
2.0 KiB
Python
49 lines
2.0 KiB
Python
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
import mock
|
|
|
|
from rally.verification.tempest import compare2html
|
|
from tests.unit import test
|
|
|
|
|
|
class Compare2HtmlTestCase(test.TestCase):
|
|
|
|
@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,
|
|
"type": "CHANGED", "test_name": u"test.two"},
|
|
{"val2": 1.11, "field": u"time", "val1": 2.22,
|
|
"type": "CHANGED", "test_name": u"test.three"}]
|
|
|
|
fake_template_kw = {
|
|
"heading": {
|
|
"title": compare2html.__title__,
|
|
"description": compare2html.__description__,
|
|
"parameters": [("Difference Count", len(results))]
|
|
},
|
|
"generator": "compare2html %s" % compare2html.__version__,
|
|
"results": results
|
|
}
|
|
|
|
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")
|