def test_slack_inst_should_print_measurement(mock_webclient, slack, mocker): dataset = mocker.MagicMock() dataset.fraction_complete.return_value = 0.123 mocker.patch('qcodes.utils.slack.active_data_set', return_value=dataset) slack.print_measurement_information(channel='CH234') print(mock_webclient.chat_postMessage.calls) text1 = 'Measurement is {:.0f}% complete'.format(0.123 * 100) expected_out1 = {'channel': 'CH234', 'text': text1} expected_out2 = {'channel': 'CH234', 'text': AnyStringWith('MagicMock')} actual = mock_webclient.chat_postMessage.call_args_list expected = [call(**expected_out1), call(**expected_out2)] assert actual == expected
def test_slack_inst_should_print_measurement_wo_latest(mock_webclient, slack): slack.print_measurement_information(channel='CH234') expected_output = {'channel': 'CH234', 'text': 'No latest dataset found'} mock_webclient.chat_postMessage.assert_called_with(**expected_output)