def test_storyerror_internal(patch): """ Ensures that an internal error gets properly constructed """ patch.object(StoryError, 'unnamed_error') e = StoryError.internal_error(Exception('ICE happened')) msg = ( 'Internal error occured: ICE happened\n' 'Please report at https://github.com/storyscript/storyscript/issues') StoryError.unnamed_error.assert_called_with(msg) assert e == StoryError.internal_error(msg)
def test_storyerror_internal(patch): """ Ensures that an internal error gets properly constructed """ patch.init(StoryError) e = Exception('.ICE.') error = StoryError.internal_error(e) assert isinstance(error, StoryError) StoryError.__init__.assert_called_with(e, story=None)
def test_api_load_story_error(patch, magic): """ Ensures Api.loads handles unknown errors """ patch.init(Story) patch.object(Story, "from_stream") Story.from_stream.side_effect = StoryError.internal_error(".error.") stream = magic() s = Api.load(stream) e = s.errors()[0] assert e.message().startswith("E0001: Internal error occured: .error.")