Skip to content

Commit

Permalink
Merge pull request #3738 from VesnaT/fix_test_plot_once
Browse files Browse the repository at this point in the history
[FIX] ProjectionWidgetTestMixin: Fix test_plot_once
  • Loading branch information
pavlin-policar authored Apr 19, 2019
2 parents 9cf23e6 + 441f044 commit f92ed93
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Orange/widgets/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -967,15 +967,17 @@ def test_plot_once(self, timeout=DEFAULT_TIMEOUT):
self.widget.setup_plot = Mock()
self.widget.commit = Mock()
self.send_signal(self.widget.Inputs.data, table)
self.widget.setup_plot.assert_called_once()
self.widget.commit.assert_called_once()

if self.widget.isBlocking():
spy = QSignalSpy(self.widget.blockingStateChanged)
self.assertTrue(spy.wait(timeout))
self.widget.setup_plot.assert_called_once()
self.widget.commit.assert_called_once()

self.widget.commit.reset_mock()
self.send_signal(self.widget.Inputs.data_subset, table[::10])
if self.widget.isBlocking():
spy = QSignalSpy(self.widget.blockingStateChanged)
self.assertTrue(spy.wait(timeout))
self.widget.setup_plot.assert_called_once()
self.widget.commit.assert_called_once()

Expand Down
17 changes: 17 additions & 0 deletions Orange/widgets/unsupervised/tests/test_owmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,23 @@ def tearDown(self):
self.widget.onDeleteWidget()
super().tearDown()

def test_plot_once(self, timeout=5000):
"""Test if data is plotted only once but committed on every input change"""
table = Table("heart_disease")
self.widget.setup_plot = Mock()
self.widget.commit = Mock()
self.send_signal(self.widget.Inputs.data, table)
self.widget.commit.reset_mock()
self.wait_until_stop_blocking()
self.widget.setup_plot.assert_called_once()
self.widget.commit.assert_called_once()

self.widget.commit.reset_mock()
self.send_signal(self.widget.Inputs.data_subset, table[::10])
self.wait_until_stop_blocking()
self.widget.setup_plot.assert_called_once()
self.widget.commit.assert_called_once()

def test_pca_init(self):
self.send_signal(self.signal_name, self.signal_data)
output = self.get_output(self.widget.Outputs.annotated_data, wait=1000)
Expand Down

0 comments on commit f92ed93

Please sign in to comment.