summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qtip/reporter/base.py14
-rw-r--r--qtip/reporter/console.py (renamed from qtip/reporter/console/__init__.py)14
-rw-r--r--qtip/reporter/templates/timeline.j2 (renamed from qtip/reporter/console/timeline.j2)0
-rw-r--r--tests/unit/reporter/console_test.py29
4 files changed, 40 insertions, 17 deletions
diff --git a/qtip/reporter/base.py b/qtip/reporter/base.py
deleted file mode 100644
index b931d14d..00000000
--- a/qtip/reporter/base.py
+++ /dev/null
@@ -1,14 +0,0 @@
-##############################################################################
-# Copyright (c) 2016 ZTE Corp and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-
-class BaseReporter(object):
- """benchmark result reporter"""
- def __init__(self, collector=None):
- self.collector = collector
diff --git a/qtip/reporter/console/__init__.py b/qtip/reporter/console.py
index 02d63288..24c98e74 100644
--- a/qtip/reporter/console/__init__.py
+++ b/qtip/reporter/console.py
@@ -7,9 +7,17 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+from qtip.base import BaseActor
-from qtip.reporter.base import BaseReporter
+class ConsoleReporter(BaseActor):
+ """
+ report benchmark result to console
+ """
+ def __init__(self, config, parent=None):
+ super(ConsoleReporter, self).__init__(config, parent=parent)
+ # TODO(yujunz) remove PoC code
+ self._fmt = "{title}: {description}"
-class ConsoleReporter(BaseReporter):
- """report result to console"""
+ def render(self, var_dict):
+ return self._fmt.format(**var_dict)
diff --git a/qtip/reporter/console/timeline.j2 b/qtip/reporter/templates/timeline.j2
index 9c18a996..9c18a996 100644
--- a/qtip/reporter/console/timeline.j2
+++ b/qtip/reporter/templates/timeline.j2
diff --git a/tests/unit/reporter/console_test.py b/tests/unit/reporter/console_test.py
new file mode 100644
index 00000000..8150239e
--- /dev/null
+++ b/tests/unit/reporter/console_test.py
@@ -0,0 +1,29 @@
+##############################################################################
+# Copyright (c) 2017 ZTE Corporation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+import pytest
+from qtip.reporter.console import ConsoleReporter
+
+
+@pytest.fixture
+def console_reporter():
+ return ConsoleReporter({})
+
+
+def test_constructor(console_reporter):
+ assert isinstance(console_reporter, ConsoleReporter)
+
+
+def test_render(console_reporter):
+ var_dict = {
+ 'title': 'fake title',
+ 'description': 'fake description'
+ }
+ output = console_reporter.render(var_dict=var_dict)
+ assert output == 'fake title: fake description'