def test_slack_instance_should_update_with_task_returning_true(slack, mocker): mocker.patch('qcodes.utils.slack.active_loop', return_value=not None) slack.add_task('finished', channel='CH234') slack.update() task_added = slack.tasks[-1] assert 'Slack.check_msmt_finished' in str(task_added.func)
def test_slack_instance_should_update_with_exception(slack, mocker): method_name = 'qcodes.utils.slack.Slack.get_new_im_messages' mock_get_new_im_messages = mocker.patch(method_name) mocker.patch('warnings.warn') mocker.patch('logging.info') for exception in [ReadTimeout, HTTPError, ConnectTimeout, ReadTimeoutError('pool', 'url', 'message')]: mock_get_new_im_messages.side_effect = exception slack.update() assert slack.tasks == []
def test_slack_instance_should_update_with_task_returning_false(slack): slack.add_task('finished', channel='CH234') slack.update() assert slack.tasks == []
def test_slack_instance_should_update(slack): slack.update() assert slack.tasks == []