def test_check_warnings_exists(ds: IdexDatastream): msg = {'warnings': ['warning1', 'warning2']} ds._logger.warning = Mock() ds._check_warnings(msg) assert ds._logger.warning.call_count == 2
def test_check_warnings_not_exists(ds: IdexDatastream): msg = {} ds._logger.warning = Mock() ds._check_warnings(msg) ds._logger.warning.assert_not_called()
def test_process_message_sub_response(ds: IdexDatastream): msg = '{"payload":"{"some": "data"}"}' decoded_msg = {1: 2} sub_response = {3: 4} ds._decode = Mock() ds._decode.return_value = decoded_msg ds._check_warnings = Mock() ds._check_errors = Mock() ds._check_sid = Mock() ds.sub_manager.is_sub_response = Mock() ds.sub_manager.is_sub_response.return_value = True ds.sub_manager.process_sub_response = Mock() ds.sub_manager.process_sub_response.return_value = sub_response result = ds._process_message(msg) ds._decode.assert_called_with(msg) ds.sub_manager.is_sub_response.assert_called_once_with(decoded_msg) ds.sub_manager.process_sub_response.assert_called_once_with(decoded_msg) ds._check_warnings.assert_called_once_with(decoded_msg) ds._check_errors.assert_called_once_with(decoded_msg) ds._check_sid.assert_called_once_with(decoded_msg) assert result == sub_response