Skip to content

Commit

Permalink
Add Unit Tests for counter, update ToolTip
Browse files Browse the repository at this point in the history
Ref #270
  • Loading branch information
algorys committed Mar 12, 2018
1 parent 0876fe7 commit 23e362b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
2 changes: 2 additions & 0 deletions alignak_app/qobjects/common/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ def initialize(self, item):
self.acknowledge_btn.setIcon(QIcon(settings.get_image('acknowledge')))
self.acknowledge_btn.setFixedSize(80, 20)
self.acknowledge_btn.clicked.connect(self.add_acknowledge)
self.acknowledge_btn.setToolTip(_('Acknowledge the current item ?'))
layout.addWidget(self.acknowledge_btn)

self.downtime_btn.setIcon(QIcon(settings.get_image('downtime')))
self.downtime_btn.setFixedSize(80, 20)
self.downtime_btn.clicked.connect(self.add_downtime)
self.downtime_btn.setToolTip(_('Schedule a Downtime on current item ?'))
layout.addWidget(self.downtime_btn)

layout.setAlignment(Qt.AlignCenter)
Expand Down
6 changes: 3 additions & 3 deletions alignak_app/qobjects/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def initialize(self):

# Synthesis
self.tab_widget.addTab(self.get_synthesis_widget(), _("Host Synthesis"))
self.tab_widget.setTabToolTip(0, _('See a synthesis view of a host'))

# Problems
problems_widget = ProblemsQWidget()
Expand All @@ -96,10 +97,12 @@ def initialize(self):
problems_widget,
_('Problems (%d)') % len(data_manager.get_problems()['problems'])
)
self.tab_widget.setTabToolTip(1, _('See the problems found in the backend'))

# Spied hosts
self.spy_widget.initialize()
self.tab_widget.addTab(self.spy_widget, _('Spied Hosts'))
self.tab_widget.setTabToolTip(2, 'See the hosts spied by Alignak-app')

# Hide widget for first display
self.host_widget.hide()
Expand Down Expand Up @@ -193,9 +196,6 @@ def spy_host(self):
)
self.spy_button.setText(self.spy_text[True])

self.spy_button.style().unpolish(self.spy_button)
self.spy_button.style().polish(self.spy_button)

def update_panel_spytab(self):
"""
Update text of the psy panel tab
Expand Down
24 changes: 23 additions & 1 deletion test/test_panel_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ def test_create_widget(self):
under_test.hostnames_list
)

# 10 problems for CRITICAL services
self.assertEqual('Problems (10)', under_test.tab_widget.tabText(1))

def test_spy_host(self):
"""Panel Add Spy Host"""

Expand All @@ -140,12 +143,31 @@ def test_spy_host(self):
under_test.line_search.setText('no_host')
under_test.spy_host()
self.assertTrue(under_test.spy_button.isEnabled())
self.assertEqual('Spied Hosts', under_test.tab_widget.tabText(2))
# Host Id is not added in spied_hosts of SpyQWidget.SpyQListWidget
self.assertFalse('_id0' in under_test.spy_widget.spy_list_widget.spied_hosts)

# Host is in hostname_list
under_test.line_search.setText('host0')
under_test.spy_host()
self.assertFalse(under_test.spy_button.isEnabled())
self.assertEqual('Spied Hosts (1)', under_test.tab_widget.tabText(2))
# Host Id is added in spied_hosts of SpyQWidget.SpyQListWidget
self.assertTrue('_id0' in under_test.spy_widget.spy_list_widget.spied_hosts)
self.assertTrue('_id0' in under_test.spy_widget.spy_list_widget.spied_hosts)

def test_update_panels(self):
"""Update QTabPanel Problems"""

under_test = PanelQWidget()
under_test.initialize()

# 10 problems for CRITICAL services
self.assertEqual('Problems (10)', under_test.tab_widget.tabText(1))

# Make a service Acknowledged (True)
data_manager.update_item_data('service', '_id0', {'ls_acknowledged': True})

under_test.tab_widget.widget(1).update_problems_data()

# There are only 9 services in CRITICAL condition
self.assertEqual('Problems (9)', under_test.tab_widget.tabText(1))

0 comments on commit 23e362b

Please sign in to comment.