Ejemplo n.º 1
0
def test_api_load(patch, magic):
    """
    Ensures Api.load can compile stories from a file stream
    """
    patch.object(Story, 'from_stream')
    stream = magic()
    result = Api.load(stream).result()
    Story.from_stream.assert_called_with(stream)
    Story.from_stream().process.assert_called()
    story = Story.from_stream().process()
    assert result == {stream.name: story, 'services': story['services']}
Ejemplo n.º 2
0
def test_api_load(patch, magic):
    """
    Ensures Api.load can compile stories from a file stream
    """
    patch.init(Features)
    patch.object(Story, "from_stream")
    stream = magic()
    result = Api.load(stream).result()
    Story.from_stream.assert_called_with(stream, ANY)
    assert isinstance(Story.from_stream.call_args[0][1], Features)
    Story.from_stream().process.assert_called()
    story = Story.from_stream().process()
    assert result == {stream.name: story, "services": story["services"]}
Ejemplo n.º 3
0
def test_story_from_stream(patch, magic):
    patch.init(Story)
    patch.object(Story, 'clean_source')
    stream = magic()
    result = Story.from_stream(stream)
    Story.__init__.assert_called_with(stream.read())
    assert isinstance(result, Story)
Ejemplo n.º 4
0
def test_story_comments_multiline_catastrophic():
    """
    Certain regular expressions will work correctly on short comments, but
    fail on longer ones because of backtracking.
    """
    stream = StringIO('###\nFiller filler filler filler\n\n###\nx = 0')
    story = Story.from_stream(stream)
    assert story.story == '\n\n\n\nx = 0'
Ejemplo n.º 5
0
def test_story_from_stream(patch, magic):
    patch.init(Story)
    stream = magic()
    result = Story.from_stream(stream, features=None)
    Story.__init__.assert_called_with(stream.read(), None)
    assert isinstance(result, Story)
Ejemplo n.º 6
0
def test_story_from_stream():
    stream = StringIO("x = 0")
    story = Story.from_stream(stream, features=None)
    assert story.story == "x = 0"
Ejemplo n.º 7
0
def test_story_from_stream():
    stream = StringIO('x = 0')
    story = Story.from_stream(stream)
    assert story.story == 'x = 0'
Ejemplo n.º 8
0
def test_story_comments_nested():
    stream = StringIO('###\nmultiline\n# nested\n###')
    story = Story.from_stream(stream)
    assert story.story == '\n\n\n'
Ejemplo n.º 9
0
def test_story_comments_multiline_idented():
    stream = StringIO('function test\n\t###\nmultiline\n\t###\n\tx = 0')
    story = Story.from_stream(stream)
    assert story.story == 'function test\n\t\n\n\n\tx = 0'
Ejemplo n.º 10
0
def test_story_comments_indented():
    stream = StringIO('function test\n\t# comment\n\tx = 0')
    story = Story.from_stream(stream)
    assert story.story == 'function test\n\t\n\tx = 0'
Ejemplo n.º 11
0
def test_story_comments():
    stream = StringIO('# comment')
    story = Story.from_stream(stream)
    assert story.story == ''