Пример #1
0
def test_bundle_bundle_trees_ebnf(patch, bundle):
    patch.many(Bundle, ['find_stories', 'parse', 'parser'])
    bundle.bundle_trees(ebnf='ebnf')
    Bundle.parser.assert_called_with('ebnf')
    Bundle.parse.assert_called_with(Bundle.find_stories(),
                                    parser=Bundle.parser(),
                                    lower=False)
Пример #2
0
def test_bundle_bundle_trees_ebnf(patch, bundle):
    patch.many(Bundle, ["find_stories", "parse", "parser"])
    bundle.bundle_trees(ebnf="ebnf")
    Bundle.parser.assert_called_with("ebnf")
    Bundle.parse.assert_called_with(Bundle.find_stories(),
                                    parser=Bundle.parser(),
                                    lower=False)
Пример #3
0
def test_bundle_bundle_trees(patch, bundle):
    patch.many(Bundle, ['find_stories', 'parse', 'parser'])
    result = bundle.bundle_trees()
    Bundle.parser.assert_called_with(None)
    Bundle.parse.assert_called_with(Bundle.find_stories(),
                                    parser=Bundle.parser(),
                                    lower=False)
    assert result == bundle.stories
Пример #4
0
def test_bundle_bundle_lower(patch, bundle, magic):
    patch.many(Bundle, ['find_stories', 'parse', 'parser'])
    a_story = magic()
    bundle.stories = {'foo': a_story}
    bundle.bundle_trees(ebnf='ebnf', lower=True)
    Bundle.parser.assert_called_with('ebnf')
    Bundle.parse.assert_called_with(Bundle.find_stories(),
                                    parser=Bundle.parser(),
                                    lower=True)
Пример #5
0
def test_bundle_bundle(patch, bundle):
    patch.many(Bundle, ['find_stories', 'services', 'compile', 'parser'])
    result = bundle.bundle()
    Bundle.parser.assert_called_with(None)
    Bundle.compile.assert_called_with(Bundle.find_stories(),
                                      parser=Bundle.parser())
    expected = {'stories': bundle.stories, 'services': Bundle.services(),
                'entrypoint': Bundle.find_stories()}
    assert result == expected
Пример #6
0
def test_bundle_bundle_lower(patch, bundle, magic):
    patch.many(Bundle, ["find_stories", "parse", "parser"])
    a_story = magic()
    bundle.stories = {"foo": a_story}
    bundle.bundle_trees(ebnf="ebnf", lower=True)
    Bundle.parser.assert_called_with("ebnf")
    Bundle.parse.assert_called_with(Bundle.find_stories(),
                                    parser=Bundle.parser(),
                                    lower=True)
Пример #7
0
def test_bundle_lex_ebnf(patch, bundle):
    """
    Ensures Bundle.lex supports specifying an ebnf file
    """
    patch.object(Story, 'from_file')
    patch.object(Bundle, 'find_stories', return_value=['story'])
    patch.object(Bundle, 'parser')
    bundle.lex(ebnf='ebnf')
    Bundle.parser.assert_called_with('ebnf')
    Story.from_file().lex.assert_called_with(parser=Bundle.parser())
Пример #8
0
def test_bundle_lex_ebnf(patch, bundle):
    """
    Ensures Bundle.lex supports specifying an ebnf file
    """
    patch.object(Story, "from_file")
    patch.object(Bundle, "find_stories", return_value=["story"])
    patch.object(Bundle, "parser")
    bundle.lex(ebnf="ebnf")
    Bundle.parser.assert_called_with("ebnf")
    Story.from_file().lex.assert_called_with(parser=Bundle.parser())
Пример #9
0
def test_bundle_lex(patch, bundle):
    """
    Ensures Bundle.lex can lex a bundle
    """
    patch.object(Story, 'from_file')
    patch.object(Bundle, 'find_stories', return_value=['story'])
    patch.object(Bundle, 'parser')
    result = bundle.lex()
    Story.from_file.assert_called_with('story', features=bundle.features)
    Bundle.parser.assert_called_with(None)
    Story.from_file().lex.assert_called_with(parser=Bundle.parser())
    assert result['story'] == Story.from_file().lex()
Пример #10
0
def test_bundle_lex(patch, bundle):
    """
    Ensures Bundle.lex can lex a bundle
    """
    patch.object(Story, "from_file")
    patch.object(Bundle, "find_stories", return_value=["story"])
    patch.object(Bundle, "parser")
    result = bundle.lex()
    Story.from_file.assert_called_with("story", features=bundle.features)
    Bundle.parser.assert_called_with(None)
    Story.from_file().lex.assert_called_with(parser=Bundle.parser())
    assert result["story"] == Story.from_file().lex()
Пример #11
0
def test_bundle_bundle(patch, bundle):
    patch.many(Bundle, ["find_stories", "services", "compile", "parser"])
    result = bundle.bundle()
    Bundle.parser.assert_called_with(None)
    Bundle.compile.assert_called_with(Bundle.find_stories(),
                                      parser=Bundle.parser())
    expected = (
        {
            "stories": bundle.stories,
            "services": Bundle.services(),
            "entrypoint": Bundle.find_stories(),
        },
        bundle.deprecations,
    )
    assert result == expected
Пример #12
0
def test_bundle_bundle_ebnf(patch, bundle):
    patch.many(Bundle, ['find_stories', 'services', 'compile', 'parser'])
    bundle.bundle(ebnf='ebnf')
    Bundle.parser.assert_called_with('ebnf')
    Bundle.compile.assert_called_with(Bundle.find_stories(),
                                      parser=Bundle.parser())
Пример #13
0
def test_bundle_bundle_ebnf(patch, bundle):
    patch.many(Bundle, ["find_stories", "services", "compile", "parser"])
    bundle.bundle(ebnf="ebnf")
    Bundle.parser.assert_called_with("ebnf")
    Bundle.compile.assert_called_with(Bundle.find_stories(),
                                      parser=Bundle.parser())