def test_unpack_message_broken_json(): mock_message = mock.Mock(data='broken.json') with pytest.raises(json.JSONDecodeError): SlackBot._unpack_message(mock_message)
def test_unpack_message_no_data(): with pytest.raises(AttributeError): SlackBot._unpack_message(object())
def test_unpack_message_success(): data = {'bar': 'foo'} mock_message = mock.Mock(data=json.dumps(data)) assert SlackBot._unpack_message(mock_message) == data
def test_unpack_message_broken_json(): mock_message = mock.Mock(data='broken.json') with pytest.raises(json.JSONDecodeError): SlackBot._unpack_message(mock_message)
def test_unpack_message_no_data(): with pytest.raises(AttributeError): SlackBot._unpack_message(object())
def test_unpack_message_success(): data = {'bar': 'foo'} mock_message = mock.Mock(data=json.dumps(data)) assert SlackBot._unpack_message(mock_message) == data