'Test if check_sql_input is called when data is sent to a widget.'

def test_inputs_check_sql(self):

    d = Table()
    self.send_signal(self.widget.Inputs.data, d)
    self.assertIs(self.widget.pop_called_with(), d)
    a_table = object()
    with patch('Orange.widgets.utils.sql.Table', MagicMock(return_value=a_table)) as table_mock:
        d = SqlTable(None, None, MagicMock())
        d.approx_len = MagicMock(return_value=(AUTO_DL_LIMIT - 1))
        self.send_signal(self.widget.Inputs.data, d)
        table_mock.assert_called_once_with(d)
        self.assertIs(self.widget.pop_called_with(), a_table)
        table_mock.reset_mock()
        d.approx_len = MagicMock(return_value=(AUTO_DL_LIMIT + 1))
        self.send_signal(self.widget.Inputs.data, d)
        table_mock.assert_not_called()
        self.assertIs(self.widget.pop_called_with(), None)
        self.assertTrue(self.widget.Error.download_sql_data.is_shown())
        table_mock.reset_mock()
        self.send_signal(self.widget.Inputs.data, None)
        table_mock.assert_not_called()
        self.assertIs(self.widget.pop_called_with(), None)
        self.assertFalse(self.widget.Error.download_sql_data.is_shown())
