yandex-tank/Tests/ConsoleOnlinePluginTest.py

69 lines
1.7 KiB
Python
Raw Normal View History

2012-09-12 13:18:58 +00:00
from Tank.Plugins.ConsoleOnline import ConsoleOnlinePlugin, AbstractInfoWidget, \
RealConsoleMarkup
from Tests.TankTests import TankTestCase
import tempfile
import unittest
from Tank.Plugins.ConsoleScreen import krutilka
2012-09-12 13:18:58 +00:00
class FakeConsoleMarkup(RealConsoleMarkup):
clear = "\n[clear]\n"
2012-09-14 16:12:46 +00:00
new_line = "\n"
YELLOW = '<y>'
RED = '<r>'
RED_DARK = '<rd>'
RESET = '<rst>'
CYAN = "<c>"
2012-10-03 12:37:15 +00:00
WHITE = "<w>"
2012-09-14 16:12:46 +00:00
GREEN = "<g>"
MAGENTA = '<m>'
BG_MAGENTA = '<M>'
BG_GREEN = '<G>'
2012-09-12 13:18:58 +00:00
class ConsoleOnlinePluginTestCase(TankTestCase):
def setUp(self):
2012-09-21 11:47:37 +00:00
core = self.get_core()
2012-09-12 13:18:58 +00:00
core.load_configs(['config/console.conf'])
core.load_plugins()
self.foo = ConsoleOnlinePlugin(core)
self.foo.console_markup = FakeConsoleMarkup()
2012-09-12 13:18:58 +00:00
def tearDown(self):
del self.foo
self.foo = None
2012-09-12 13:18:58 +00:00
def test_run(self):
2012-10-03 12:37:15 +00:00
self.data = self.get_aggregate_data('data/preproc_single2.txt')
self.foo.set_option('disable_colors', 'WHITE')
2012-09-12 13:18:58 +00:00
self.foo.configure()
self.foo.prepare_test()
self.foo.add_info_widget(TestWidget())
self.foo.add_info_widget(TestWidget2())
self.foo.start_test()
k=krutilka()
2012-09-12 13:18:58 +00:00
for i in range(1, 10):
print k.next()
2012-09-12 13:18:58 +00:00
self.foo.aggregate_second(self.data)
self.foo.end_test(0)
self.assertFalse(self.foo.render_exception)
2012-09-12 13:18:58 +00:00
class TestWidget(AbstractInfoWidget):
def render(self, screen):
return "Widget Data";
class TestWidget2(AbstractInfoWidget):
def get_index(self):
return 100;
def render(self, screen):
return "Widget Data 2";
if __name__ == '__main__':
unittest.main()