Skip to content

Commit

Permalink
Merge pull request #4502 from aturanjanin/owpurgedomain
Browse files Browse the repository at this point in the history
[ENH] OWPurgeDomain: Data info displayed in the status bar
  • Loading branch information
VesnaT authored Mar 13, 2020
2 parents 17e9691 + aae8c47 commit 331cc84
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Orange/widgets/data/owpurgedomain.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from Orange.widgets.settings import Setting
from Orange.widgets.utils.sql import check_sql_input
from Orange.widgets.utils.widgetpreview import WidgetPreview
from Orange.widgets.utils.state_summary import format_summary_details
from Orange.widgets.widget import Input, Output


Expand Down Expand Up @@ -100,11 +101,16 @@ def __init__(self):
gui.auto_send(self.buttonsArea, self, "autoSend")
gui.rubber(self.controlArea)

self.info.set_input_summary(self.info.NoInput)
self.info.set_output_summary(self.info.NoOutput)

@Inputs.data
@check_sql_input
def setData(self, dataset):
if dataset is not None:
self.data = dataset
self.info.set_input_summary(len(dataset),
format_summary_details(dataset))
self.unconditional_commit()
else:
self.removedAttrs = "-"
Expand All @@ -117,6 +123,8 @@ def setData(self, dataset):
self.reducedMetas = "-"
self.Outputs.data.send(None)
self.data = None
self.info.set_input_summary(self.info.NoInput)
self.info.set_output_summary(self.info.NoOutput)

def optionsChanged(self):
self.commit()
Expand Down Expand Up @@ -149,6 +157,8 @@ def commit(self):
self.removedMetas = meta_res['removed']
self.reducedMetas = meta_res['reduced']

self.info.set_output_summary(len(cleaned),
format_summary_details(cleaned))
self.Outputs.data.send(cleaned)

def send_report(self):
Expand Down
32 changes: 32 additions & 0 deletions Orange/widgets/data/tests/test_owpurgedomain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# pylint: disable=unsubscriptable-object
from unittest.mock import Mock

from Orange.data import Table
from Orange.widgets.data.owpurgedomain import OWPurgeDomain
from Orange.widgets.tests.base import WidgetTest
from Orange.widgets.utils.state_summary import format_summary_details


class TestOWPurgeDomain(WidgetTest):
def setUp(self):
self.widget = self.create_widget(OWPurgeDomain)
self.iris = Table("iris")

def test_summary(self):
"""Check if the status bar is updated when data is received"""
data = self.iris
input_sum = self.widget.info.set_input_summary = Mock()
output_sum = self.widget.info.set_output_summary = Mock()

self.send_signal(self.widget.Inputs.data, data)
input_sum.assert_called_with(len(data), format_summary_details(data))
output = self.get_output(self.widget.Outputs.data)
output_sum.assert_called_with(len(output),
format_summary_details(output))
input_sum.reset_mock()
output_sum.reset_mock()
self.send_signal(self.widget.Inputs.data, None)
input_sum.assert_called_once()
self.assertEqual(input_sum.call_args[0][0].brief, "")
output_sum.assert_called_once()
self.assertEqual(output_sum.call_args[0][0].brief, "")

0 comments on commit 331cc84

Please sign in to comment.