aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYujun Zhang <zhang.yujunz@zte.com.cn>2017-04-20 12:58:47 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-04-20 12:58:47 +0000
commit1227dc7e737e9946f316c7693232a9f5cbe166ed (patch)
treeef5864102712a9cfbca26c511fabfd270e896746 /tests
parenta1325130fdbbab0c58a08d636b8c0419504020a8 (diff)
parent90e6893b967cded4bf45380d643d3bfcb19ce0d4 (diff)
Merge "Set default width to 80 for justify filter"
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/cli/cmd_report_test.py66
-rw-r--r--tests/unit/reporter/console_test.py66
2 files changed, 22 insertions, 110 deletions
diff --git a/tests/unit/cli/cmd_report_test.py b/tests/unit/cli/cmd_report_test.py
index 21e757d8..064ed8fd 100644
--- a/tests/unit/cli/cmd_report_test.py
+++ b/tests/unit/cli/cmd_report_test.py
@@ -26,60 +26,16 @@ def result_path():
return result
-def test_dhrystone(runner, result_path):
+@pytest.mark.parametrize(['report_name'], [
+ ('dhrystone',),
+ ('whetstone',),
+ ('dpi',),
+ ('ramspeed',),
+ ('ssl',)
+])
+def test_dhrystone(report_name, runner, result_path):
"""Test dhrystone report"""
- result = runner.invoke(cli, ['report', 'show', 'dhrystone', '-p', result_path])
- assert "Benchmark..............................................................." \
- "...................dhrystone" in result.output
- assert "Score..................................................................." \
- "..................63529.6"
-
-
-def test_whetstone(runner, result_path):
- """ Test whetstone output"""
-
- result = runner.invoke(cli, ['report', 'show', 'whetstone', '-p', result_path])
- assert "Number................................................................." \
- "...........................40" in result.output
- assert "Total CPUs............................................................." \
- "...........................40"
-
-
-def test_dpi(runner, result_path):
- """ Test dpi report"""
- result = runner.invoke(cli, ['report', 'show', 'dpi', '-p', result_path])
- assert "Bits per Second..................................................." \
- ".............................3.638" in result.output
- assert "Packets per Second................................................" \
- ".............................1.458" in result.output
-
-
-def test_ramspeed(runner, result_path):
- """ Test ramspeed report """
- result = runner.invoke(cli, ['report', 'show', 'ramspeed', '-p', result_path])
- assert "Float Addition........................................................" \
- "......................10522.33" in result.output
- assert "Integer Average........................................................" \
- ".....................11466.52" in result.output
-
-
-def test_ssl(runner, result_path):
- """ Test ssl report"""
-
- result = runner.invoke(cli, ['report', 'show', 'ssl', '-p', result_path])
- assert "8192............................................................." \
- ".........................667303.94k" in result.output
- assert "1024.............................................................." \
- "..........................100088.3" in result.output
-
-
-def test_sys(runner, result_path):
- """ Test sys_info """
-
- result = runner.invoke(cli, ['report', 'show', 'ssl', '-p', result_path])
- assert "System Information" in result.output
- assert "Host Name........................................................" \
- ".................node-38.zte.com.cn" in result.output
- assert "Operating System.................................................." \
- "...............Ubuntu 16.04 xenial" in result.output
+ result = runner.invoke(cli, ['report', 'show', report_name, '-p', result_path])
+ for line in str(result).split('\n'):
+ assert len(line) <= 80
diff --git a/tests/unit/reporter/console_test.py b/tests/unit/reporter/console_test.py
index 7ece4663..11fb3f71 100644
--- a/tests/unit/reporter/console_test.py
+++ b/tests/unit/reporter/console_test.py
@@ -29,60 +29,16 @@ def test_constructor(console_reporter):
assert isinstance(console_reporter, ConsoleReporter)
-def test_dhrystone(console_reporter, result_path):
+@pytest.mark.parametrize(['template_name'], [
+ ('dhrystone',),
+ ('whetstone',),
+ ('dpi',),
+ ('ramspeed',),
+ ('ssl',)
+])
+def test_templates(template_name, console_reporter, result_path):
""" Test dhrystone report"""
- result = console_reporter.render('dhrystone', result_path)
- assert "Benchmark..............................................................." \
- "...................dhrystone" in result
-
-
-def test_whetstone(console_reporter, result_path):
- """ Test whetstone output"""
-
- result = console_reporter.render('whetstone', result_path)
- assert "Number................................................................." \
- "...........................40" in result
- assert "Total CPUs............................................................." \
- "...........................40" in result
-
-
-def test_dpi(console_reporter, result_path):
- """ Test dpi report"""
-
- result = console_reporter.render('dpi', result_path)
- assert "Bits per Second..................................................." \
- ".............................3.638" in result
- assert "Packets per Second................................................" \
- ".............................1.458" in result
-
-
-def test_ramspeed(console_reporter, result_path):
- """ Test ramspeed report """
-
- result = console_reporter.render('ramspeed', result_path)
- assert "Float Addition........................................................" \
- "......................10522.33" in result
- assert "Integer Average........................................................" \
- ".....................11466.52" in result
-
-
-def test_ssl(console_reporter, result_path):
- """ Test ssl report"""
-
- result = console_reporter.render('ssl', result_path)
- assert "8192............................................................." \
- ".........................667303.94k" in result
- assert "1024.............................................................." \
- "..........................100088.3" in result
-
-
-def test_sys(console_reporter, result_path):
- """ Test sys_info """
-
- result = console_reporter.render('ssl', result_path)
- assert "System Information" in result
- assert "Host Name........................................................" \
- ".................node-38.zte.com.cn" in result
- assert "Operating System.................................................." \
- "...............Ubuntu 16.04 xenial" in result
+ result = console_reporter.render(template_name, result_path)
+ for line in result.split('\n'):
+ assert len(line) <= 80