@@ -276,9 +276,70 @@ def setUp(self):
276276 [continuous_full , continuous_missing ],
277277 target = [rgb_full , rgb_missing ], metas = [ints_full , ints_missing ]
278278 )
279- self .send_signal ('Data' , self .data )
279+ self .send_signal (self . widget . Inputs . data , self .data )
280280 self .select_rows = partial (select_rows , widget = self .widget )
281281
282+ def test_changing_data_updates_ouput (self ):
283+ # Test behaviour of widget when auto commit is OFF
284+ self .widget .auto_commit = False
285+
286+ # We start of with some data and select some rows
287+ self .send_signal (self .widget .Inputs .data , self .data )
288+ self .select_rows ([0 ])
289+ # By default, nothing should be sent since auto commit is off
290+ self .assertIsNone (self .get_output (self .widget .Outputs .reduced_data ))
291+ self .assertIsNone (self .get_output (self .widget .Outputs .statistics ))
292+ # When we commit, the data should be on the output
293+ self .widget .unconditional_commit ()
294+ self .assertIsNotNone (self .get_output (self .widget .Outputs .reduced_data ))
295+ self .assertIsNotNone (self .get_output (self .widget .Outputs .statistics ))
296+
297+ # Send some new data
298+ iris = Table ('iris' )
299+ self .send_signal (self .widget .Inputs .data , iris )
300+ # By default, there should be nothing on the output
301+ self .assertIsNone (self .get_output (self .widget .Outputs .reduced_data ))
302+ self .assertIsNone (self .get_output (self .widget .Outputs .statistics ))
303+ # Nothing should change after commit, since we haven't selected any rows
304+ self .widget .unconditional_commit ()
305+ self .assertIsNone (self .get_output (self .widget .Outputs .reduced_data ))
306+ self .assertIsNone (self .get_output (self .widget .Outputs .statistics ))
307+
308+ # Now let's switch back to the original data, where we selected row 0
309+ self .send_signal (self .widget .Inputs .data , self .data )
310+ # Again, since auto commit is off, nothing should be on the output
311+ self .assertIsNone (self .get_output (self .widget .Outputs .reduced_data ))
312+ self .assertIsNone (self .get_output (self .widget .Outputs .statistics ))
313+ # Since the row selection is saved into context settings, the appropriate
314+ # thing should be sent to output
315+ self .widget .unconditional_commit ()
316+ self .assertIsNotNone (self .get_output (self .widget .Outputs .reduced_data ))
317+ self .assertIsNotNone (self .get_output (self .widget .Outputs .statistics ))
318+
319+ def test_changing_data_updates_output_with_autocommit (self ):
320+ # Test behaviour of widget when auto commit is ON
321+ self .widget .auto_commit = True
322+
323+ # We start of with some data and select some rows
324+ self .send_signal (self .widget .Inputs .data , self .data )
325+ self .select_rows ([0 ])
326+ # Selecting rows should send data to output
327+ self .assertIsNotNone (self .get_output (self .widget .Outputs .reduced_data ))
328+ self .assertIsNotNone (self .get_output (self .widget .Outputs .statistics ))
329+
330+ # Send some new data
331+ iris = Table ('iris' )
332+ self .send_signal (self .widget .Inputs .data , iris )
333+ # Don't select anything, so the outputs should be empty
334+ self .assertIsNone (self .get_output (self .widget .Outputs .reduced_data ))
335+ self .assertIsNone (self .get_output (self .widget .Outputs .statistics ))
336+
337+ # Now let's switch back to the original data, where we had selected row 0,
338+ # we expect that to be sent to output
339+ self .send_signal (self .widget .Inputs .data , self .data )
340+ self .assertIsNotNone (self .get_output (self .widget .Outputs .reduced_data ))
341+ self .assertIsNotNone (self .get_output (self .widget .Outputs .statistics ))
342+
282343 def test_sends_single_attribute_table_to_output (self ):
283344 # Check if selecting a single attribute row
284345 self .select_rows ([0 ])
0 commit comments